Posts tonen met het label arduino. Alle posts tonen
Posts tonen met het label arduino. Alle posts tonen

zondag 27 november 2016

weekender project: build a clock out of a plastic jar.

Make a clock with a white plastic jar, 2 adafruits neopixel rings and an arduino.

you need
1 arduino uno
1 adafruit neopixel ring 24 color leds (link)
1 adafruit neopixel ring 12 color leds (link)
1 plastic jar with lid, big enough to hold the 24 leds ring.
1 rtc module (real time clock) like this one (link)


The small ring is the small hand of a clock. 12 led's for 12 hours.
the bigger ring show's the seconds an minutes. well 2.5 minutes (seconds). Because 60 minutes diveded by 24 leds is 2.5 minutes interval. This makes the clock less accurate to read. Adafruit sels 60 led ring but it's huge, too huge.
The seconds go round in smooth way. They start to fade in and fade back out, one after another to create a fluid motion.
The minute and hour "hand" don't have this motion (yet).
The color of the hour and minute leds change during the day. At midnight till about 4 they are blue, then they start to fade to red at dusk continue to yellow at noon, in the late afternoon they fade back to orange, red, purple and blue to emulate the dawn.

The code.

You can find the code on github (link).

puzzling the pieces together

The neopixel rings are easy to put together. The rings need only 3 wires: 5v, ground and a data line. Run a wire from pin 6 on the arduino to the data in of the 24 led pin and a wire from de data out of the 24 led ring to the data in of the 12 led ring. Connect the 5 volt and ground.

The rtc module needs 5 wires: 5 volt, ground, mosi, miso and ss. They are connect to pins 10-13.

The jar.

you need a white plastic jar. The neopixels are bright. A white jar kind of smooth out the bright light.


the neo pixel ring front
neopixel rings atached to a small piece of wood

in the jar



the arduino and the rtc mounted in the lid of the jar

 

what's still missing

Button's to adjust the time. I had no right size switches of button's left, so adjusting the time can't be done without connecting the arduino to the computer and recompile the code.

zondag 3 november 2013

Deluxe thermometer with ethnernet and logging and adafruit neopixel display

the code is on github https://github.com/andrethemac/thermometer_adafruit_ethernet.git


A weekend project.
1 arduino ethernet
1 adafruit neopixel shield 8x5.
1 sht15 temperature senson
1 pressure sensor
some wire
How to wire up is explained in the ino file in github.

There are good wikis on the setup of the lighttp server, Python examples and mysql info too.

The neopixel can put a huge load on the power supply. You have to take care about that. By keeping the brightness rather low, the shield draws no more than 60 mA (a shield on full blast goes easy over 1A).
Putting a piece of paper before the neopixels makes the display more readable and clearer. (or a piece of plexiglass would do the same, just don't use a crystal clear one).
The bar graph takes 8 hours to fill up, so be patient.

zaterdag 11 mei 2013

arduino based thermometer with lcd display and logging

How to make a Deluxe thermometer with an LCD display (who know's when someone is close) and logging to a webserver.
some images

Things it should do

measures the temperature (obvious)
sends data to a webserver (and a database)
show the temperature on a display
tell's if the temperature is rising of dropping over the last
10 minutes.
Display should only work if there's somebody close to the display. This is done by using de arduino's pins to power the LCD backlight.
The backlight controlling pin goes high (backlight on) when another pin goes hight. This other pin is connect to a digital motion sensor.

materials used:

1 arduino with built in ethernet
http://arduino.cc/en/Main/ArduinoBoardEthernet
library
http://arduino.cc/en/Reference/Ethernet

1 digital motion sensor
http://www.ladyada.net/learn/sensors/pir.html
http://iprototype.be/search?search_string=pir

1 lcd 2 x 16 characters based on a Hitachi HD44780 chipset
http://iprototype.be/products/components/led-lcd/lcd16x2-BL
library:
http://arduino.cc/en/Reference/LiquidCrystal

1 NTC (temperature sensitive resistor)
http://iprototype.be/products/components/sensors/ntc

little extra: measuring light
1 ldr (light sensitive resistor)

1 breadboard and a lot of wire

steps

connect the display to the arduino
VSS connects to ground
VDD connects to +5 v
v0 connect to the slider of a 10K potentiometer (one side on the 5V, the other on the ground) RS connects to arduino D7
R/W connects to ground
E connects to arduino D6
D4-D8 connects to arduino D2-D5 (data)
K of backlight connects to ground
A of backlight connects to arduino D9

Digital Motion Sensor (pir)
connect the Red and black wires to the 5v and ground, connect the data wire to the arduino D8.

NTC
NTC is a negative temperature controller, a resistor whose value changes with the temperature. A 10K resitor is used as a pullup resistor. The analoge input (A0) is connected between the NTC and the 10 K resistor
5V --[10K]-- A0 --[NTC]-- ground.

logging the webserver.


On the webserver a cgi script for the arduino.
The script is written in python. This script passed the values on to a database.

how the breadboard was setup




Fritzing schema :  Fritzing

the code

you can download the code here: temp4.ino


/*
Andre Peeters
2013-05-11
Deluxe thermometer v0.2
measures the temperature
sends this to a webserver (and a database)
also shows the temperature on a display
tell's if the temperature is rising of dropping over the last
10 minutes.
Only shows its value if there's somebody close to the display.
(digital motion sensor)

materials used:
1 arduino with built in ethernet
http://arduino.cc/en/Main/ArduinoBoardEthernet
library
http://arduino.cc/en/Reference/Ethernet

1 digital motion sensor
http://www.ladyada.net/learn/sensors/pir.html

1 lcd 2 x 16 characters based on a Hitachi HD44780 chipset
http://iprototype.be/products/components/led-lcd/lcd16x2-BL
library:
http://arduino.cc/en/Reference/LiquidCrystal

1 NTC (temperature sensitive resistor)
http://iprototype.be/products/components/sensors/ntc

1 ldr (light sensitive resistor)

1 breadboard and a lot of wire

*/



/*
ethernet setup
*/
#include
#include
#include

// my mac address
byte mac[] = { 0x90, 0xA2, 0xDA, 0x0D, 0x8E, 0x23 };

//medion =  my server's dns name
//byte medion[] = { 192, 168, 128, 17 };
char medion[] = "medion";
EthernetClient client; //(medion, 80);
// msg to send to server
String msg;

/*
display setup
*/
// include the library code:
#include

// celsius character
byte celcius[8] = {
  B00110,
  B01001,
  B01001,
  B00110,
  B00000,
  B00000,
  B00000,
};

// arrow up character
byte up[8] = {
  B00000,
  B00100,
  B01110,
  B10101,
  B00100,
  B00100,
  B00000,
};

// arrow down character
byte down[8] = {
  B00000,
  B00100,
  B00100,
  B10101,
  B01110,
  B00100,
  B00000,
};

// line character
byte equal[8] = {
  B00000,
  B00000,
  B00000,
  B11111,
  B00000,
  B00000,
  B00000,
};

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(7, 6, 5, 4, 3, 2);

//pir (digital movement sensor)
#define pirIn 8
// lcd backlight control
#define backLight 9

// temperature
float temp;
int light;
int tempArray[] = {0,0,0,0,0,0,0,0,0,0};
int tempAverage;
int t;

//Temp and light sensor
#define InputTemp 0
#define InputLight 1

/*
convert the value messured on the NTR resistor
to celsius degree temperature
*/
// resistance at 25 degrees C
#define THERMISTORNOMINAL 10000
// temp. for nominal resistance (almost always 25 C)
#define TEMPERATURENOMINAL 25
// The beta coefficient of the thermistor (usually 3000-4000)
#define BCOEFFICIENT 4100
// the value of the 'other' resistor
#define SERIESRESISTOR 10000

double Thermister(int RawADC) {
  float average;
  average = 1023.0 / RawADC - 1;
  average = SERIESRESISTOR / average;
  float steinhart;
  steinhart = average / THERMISTORNOMINAL; // (R/Ro)
  steinhart = log(steinhart); // ln(R/Ro)
  steinhart /= BCOEFFICIENT; // 1/B * ln(R/Ro)
  steinhart += 1.0 / (TEMPERATURENOMINAL + 273.15); // + (1/To)
  steinhart = 1.0 / steinhart; // Invert
  steinhart -= 273.15; // convert to C
  return steinhart;
}


void setup() {
    // set up the LCD's number of columns and rows:
  lcd.begin(16, 2);
  // Print a message to the LCD.
  lcd.print("initial setup");
  lcd.setCursor(0,1);
  lcd.print("please wait");
  // create the special chars
  lcd.createChar(0,celcius);
  lcd.createChar(1,up);
  lcd.createChar(2,down);
  lcd.createChar(3,equal);

  // set the digital pins
  pinMode(pirIn,INPUT);
  pinMode(backLight,OUTPUT);
  digitalWrite(backLight,HIGH);

  Serial.begin(9600);
  // init temp
  temp = 0.0;
  light = 0;

  // ethernet setup
  // configure dhcp
  if ( Ethernet.begin(mac) == 0 ) {
    Serial.println("failed to configure dhcp");
    for ( ;; )
      ;
  }
  else {
    // this is my IP address
    Serial.println( Ethernet.localIP() );
  }
  // clear the lcd when setup is done
  lcd.clear();
}

void loop() {
  // get the temperature
  temp = Thermister(analogRead(InputTemp));
 
  // keep the last 10 mesure values as an int
  int tt = temp * 100;
  // shift the values in the array to the front and add the actual
  // temperatur at the back
  for(int x = 1; x < 10; x++) {
    // replace a zero value in the array with the actual temperatur
    if(tempArray[x] == 0) {
      tempArray[x] = tt;
    }
    tempArray[x-1] = tempArray[x];
  }
  tempArray[9] = tt;
 
  // calculate the average temperature over the last 10 mesurements
  tempAverage = 0;
  for(int x = 0; x < 10; x++) {
    tempAverage = tempAverage + tempArray[x] ;
  }
  tempAverage = tempAverage / 10;

  // create a string with the temperature with 2 numbers after the
  // decimal point
  t = temp * 100;
  int t1 = t / 100;
  int t2 = t % 100;
  String ts = "";
  if(t2 < 10) {
    ts = "0";
  }
  String t0 = "";
  t0 = t0 + t1 + "." + ts + t2;

  // convert the light to a number
  light = constrain(map(analogRead(InputLight),0,250,0,100),0,100);
  int l = light;

  // get things on the display
  lcd.setCursor(5,0);
  lcd.print(t0);
  lcd.write(byte(0));
  lcd.setCursor(15,0);
  if ( tempAverage == tt) {
    lcd.write(byte(3));
    lcd.setCursor(0,1);
    lcd.print("     gelijk     ");
  //lcd.print("     equal      ");
  }
  if ( tempAverage < tt) {
    lcd.write(byte(1));
    lcd.setCursor(0,1);
    lcd.print("    stijgend    ");
  //lcd.print("     rising     ");
  }
  if ( tempAverage > tt) {
    lcd.write(byte(2));
    lcd.setCursor(0,1);
    lcd.print("     dalend     ");
  //lcd.print("    dropping    ");
  }

/* 
  lcd.setCursor(0,1);
  lcd.print("light = ");
  lcd.print(l,DEC);
*/
 
  //send the temperature messured to the webserver and database
  String msg  = "GET /cgi-bin/t2.py?t=";
  String msg2 = "&l=";
  String msg3 = " HTTP/1.0";
  msg = msg + t0 + msg2 + l + msg3;
  client.connect(medion,80);
  if (client.connected()){
    Serial.println("connected");
    client.println(msg);
    client.println();
    client.stop();
  } else {
    Serial.println("error");
  }
  client.stop();

  /*
  wait a second an check the motion sensor
  if there is motion, turn on the display and the backlight
  repeat this for a minute, then measure the temperature again.
  */
  for(int x = 0; x < 60; x++) {
    //read pir and turn on the backlight if oké
    if(digitalRead(pirIn)) {
      lcd.display();
      digitalWrite(backLight,HIGH);
    } else {
      lcd.noDisplay();
      digitalWrite(backLight,LOW);
    }
   
    // blink a dot
    lcd.setCursor(15,1);
    if(x % 2) {
      lcd.print(".");
    } else {
      lcd.print(" ");
    }
    // wait a second
    delay(1000);
  }
}


donderdag 14 april 2011

Robotje poging 0.1

Benodigdheden:
1 robotplatform met 2 wielen en 2 motortjes (voorbeeld)
1 arduino uno (voorbeeld)
1 motorshield voor arduino uno (voorbeeld)
2 ir sensors (voorbeeld)

Het robotje in elkaar vijzen is eenvoudig. Om de motortjes aan te sluiten heb je wat soldeer nodig.
Het robotje is nog niet perfect. Objecten schuins vooraan worden opgemerkt en ontweken, maar wat recht voor de robot is worden niet gezien en dus niet ontweken.

de sketch:
int l_sensorPin = 0; // select the input pin for the sensor
int r_sensorPin = 1; // select the input pin for the sensor
int l_ledPin = 11; // select the pin for the LED
int r_ledPin = 10; // select the pin for the LED
int l_sensorValue = 0; // variable to store the value coming from the sensor
int r_sensorValue = 0; // variable to store the value coming from the sensor

int E1 = 4; // select the pin for the E1
int E2 = 7; // select the pin for the E2
int M1 = 5; // select the pin for the M1
int M2 = 6; // select the pin for the M2

void setup() {
pinMode(E1, OUTPUT);
pinMode(E2, OUTPUT);
}

void loop() {
// read the value from the sensor:
digitalWrite(E1,HIGH);
digitalWrite(E2,HIGH);
l_sensorValue = analogRead(l_sensorPin);
r_sensorValue = analogRead(r_sensorPin);

l_sensorValue = map(l_sensorValue,0,512,255,0);
r_sensorValue = map(r_sensorValue,0,512,255,0);

analogWrite(M1,l_sensorValue);
analogWrite(l_ledPin,l_sensorValue);
analogWrite(M2,r_sensorValue);
analogWrite(r_ledPin,r_sensorValue);
}