| Arduino Forum ::  Members :: frostin
 Show Posts Pages: [1] 2 3 ... 28
 1 Using Arduino / Programming Questions / Re: Dht22 on: August 31, 2011, 03:07:50 pm I was meaning by reading the value of c (hence it's in celcius when on or off). Couldn't I use #define 120 in f not in c by using some math or am I just going to have to calculate it only for displaying ane figure the temp I'd have to set at in c for the relay?
 2 Using Arduino / Programming Questions / Re: Dht22 on: August 28, 2011, 06:02:33 pm How so? I believe standard the library is in Celcius not fahrenheit which I had to calculate to display F Edit:Basically the relay which is connected to say pin 4 its HIGH (relay closed) crock pot will be on till about 120ish degrees F. If it goes higher than 120 then the relay will be LOW (relay open).
 3 Using Arduino / Programming Questions / Re: Dht22 on: August 28, 2011, 05:38:54 pm Didn't compile correctly... But this does:Code:#include "DHT.h"#define DHTTYPE DHT22#define DHTPIN 2DHT dht(DHTPIN, DHTTYPE);#define CROCKPOTPIN 4#define TEMP_HIGH  22#define TEMP_LOW 20#define HUMID_HIGH 60#define HUMID_LOW 20float minTemp = 100;float maxTemp = 0;float minHumid = 100;float maxHumid = 0;int crockValue = 0;void setup(){  Serial.begin(115200);  Serial.println("TEST PROGRAM ");  pinMode(CROCKPOTPIN, OUTPUT);}void loop(){  // READ DATAint t = dht.readTemperature();int temperatureF = (t * 9 / 5) +32.5;  // DO THE MIN/MAX  minTemp = min(minTemp, t);  maxTemp = max(maxTemp , t);  // DISPLAT DATA  Serial.println(temperatureF);  // CROCKPOT  if (t > TEMP_HIGH) crockValue = 1;  else if (t < TEMP_LOW) crockValue = 0;  digitalWrite(CROCKPOTPIN, crockValue);  delay(2000);  // DHT's need a delay between readings ...}
 4 Using Arduino / Programming Questions / Dht22 on: August 28, 2011, 03:07:34 pm I have the dht22 wired sensor from adafruit conected to digital pin 2. I haven't played with arduino in over a year so any help or guidance from a couple things:1:I'm using this sensor so I can activate a relay going to a crock pot. This is where it'll turn on or off at a certain temperature.2: I'm using the humidty part to know when I need to open a valve controlled by a servo to control the humidty at a certain percentage.3: I have got it working on a LCD 16x2 display temp (f) and humidty. This will be just an extra add on and later I made add a min/max feature.Also out of question (may need to be in hardware) has any interfaced this small relay off eBay that's already on a pcb? Can hardly see the pinout on silkscreen (I bought one).
 5 Community / Bar Sport / Getting rid of goodies on: February 28, 2011, 11:46:39 pm 1x arduino duemilanove1x sparkfun 5v ftdi adapter1x adafruit breadboard power supply1x wii nunchuck1x wii nunchuck adapter1x max7219 ic (dip)3x 74hc595 ics (dip)1x glcd 1x usbtinyisp avr programmer2 USB cables (one for arduino, one for ftdi)Want to get rid of in one batch.Pm me.
 6 Forum 2005-2010 (read only) / Syntax & Programs / Re: GLCD Wii Tilt Code on: August 10, 2010, 08:59:42 pm @memNo more flickering The DrawLine isn't even at at the center of the Horizontal line.
 7 Forum 2005-2010 (read only) / Syntax & Programs / Re: GLCD Wii Tilt Code on: August 08, 2010, 09:42:46 pm I tried and I dont get anything from the display. Nothing in serial monitor. I took out the loop_cnt. Could be why it isn't displaying anything. Maybe I've got it coded wrong... I tried this:Code:#include #include "fonts/Arial14.h"         // proportional font#include "fonts/SystemFont5x7.h"   // system font#include // initialize wire#include "nunchuck_funcs.h"byte accx;void setup(){  Serial.begin(19200);  nunchuck_setpowerpins();  nunchuck_init();  GLCD.Init(NON_INVERTED);  GLCD.SelectFont(System5x7);}void loop(){  if( accx >= 75 && accx <= 185)  {    nunchuck_get_data();    accx  = nunchuck_accelx();    Serial.println((byte)accx,DEC);    byte  y = map(accx, 75, 185, 0, 63); // map returns a value from 0 to 63 for values from 75 to 185    GLCD.ClearScreen();    GLCD.DrawHLine(0, 32, 127);    GLCD.DrawLine(0, 63-y, 127, y);       // draw the line  }  delay(100); // the time in milliseconds between redraws}
 8 Forum 2005-2010 (read only) / Syntax & Programs / Re: GLCD Wii Tilt Code on: August 07, 2010, 10:46:59 pm This works surprisingly I have a tiny bit of flicker from 64,32 all the way to 127, 0 its not bad.Code:#include #include "fonts/Arial14.h"         // proportional font#include "fonts/SystemFont5x7.h"   // system font#include // initialize wire#include "nunchuck_funcs.h"int loop_cnt=0;byte accx;void setup(){  Serial.begin(19200);  nunchuck_setpowerpins();  nunchuck_init();  GLCD.Init(NON_INVERTED);  GLCD.ClearScreen();  GLCD.SelectFont(System5x7);  Serial.print("Wii nunchuck ready");  GLCD.DrawHLine(0, 32, 127);}void loop(){   if( loop_cnt > 100 )         loop_cnt = 0;        nunchuck_get_data();        accx  = nunchuck_accelx();        Serial.println((byte)accx,DEC);    if ((accx <= 185) && (accx > 180)){  GLCD.ClearScreen();  GLCD.DrawHLine(0, 32, 127);  GLCD.DrawLine(0, 0, 127, 63);}else if(( accx < 180) && (accx >= 175)){GLCD.ClearScreen();  GLCD.DrawHLine(0, 32, 127);  GLCD.DrawLine(0 , 3, 127, 60);   }else if ((accx <= 175) && (accx > 170)){GLCD.ClearScreen();  GLCD.DrawHLine(0, 32, 127);GLCD.DrawLine(0, 6, 127, 57);}else if((accx < 170) && (accx >= 165)){  GLCD.ClearScreen();  GLCD.DrawHLine(0, 32, 127);  GLCD.DrawLine(0, 9, 127, 54);   }  else if((accx <= 165) && (accx > 160))  {      GLCD.ClearScreen();  GLCD.DrawHLine(0, 32, 127);  GLCD.DrawLine(0, 12, 127, 51);  }  else if((accx < 160) && (accx >= 155))  {      GLCD.ClearScreen();  GLCD.DrawHLine(0, 32, 127);  GLCD.DrawLine(0, 15, 127, 48);  }  else if((accx <= 155) && (accx > 150))    {GLCD.ClearScreen();  GLCD.DrawHLine(0, 32, 127);  GLCD.DrawLine(0, 18, 127, 45);    }    else if((accx < 150) && (accx >= 145))    {    GLCD.ClearScreen();    GLCD.DrawHLine(0, 32, 127);    GLCD.DrawLine(0, 21, 127, 42);   }   else if((accx <= 145) && (accx > 140))   {      GLCD.ClearScreen();    GLCD.DrawHLine(0, 32, 127);    GLCD.DrawLine(0, 24, 127, 39);   }   else if((accx < 140) && (accx >= 135))   {    GLCD.ClearScreen();    GLCD.DrawHLine(0, 32, 127);    GLCD.DrawLine(0, 27, 127, 36);   }      else if((accx <= 135) && (accx > 130))   {      GLCD.ClearScreen();    GLCD.DrawHLine(0, 32, 127);    GLCD.DrawLine(0, 30, 127, 33);   }    else if((accx < 130) && (accx >= 125))    {    GLCD.ClearScreen();    GLCD.DrawHLine(0, 32, 127);    GLCD.DrawLine(0, 32, 127, 32);   }       else if((accx <= 125) && (accx > 120))       {        GLCD.ClearScreen();    GLCD.DrawHLine(0, 32, 127);    GLCD.DrawLine(0, 34, 127, 31);       }       else if((accx < 120) && (accx >= 115))       {          GLCD.ClearScreen();    GLCD.DrawHLine(0, 32, 127);    GLCD.DrawLine(0, 37, 127, 28);       }    else if((accx <= 115) && (accx > 110))    {     GLCD.ClearScreen();    GLCD.DrawHLine(0, 32, 127);    GLCD.DrawLine(0, 40, 127, 25);   }   else if((accx < 110) && (accx >= 105))   {    GLCD.ClearScreen();    GLCD.DrawHLine(0, 32, 127);    GLCD.DrawLine(0, 43, 127, 22);   }   else if((accx <= 105) && (accx > 100))   {         GLCD.ClearScreen();    GLCD.DrawHLine(0, 32, 127);    GLCD.DrawLine(0, 46, 127, 19);   }   else if((accx < 100) && (accx >= 95))    {    GLCD.ClearScreen();    GLCD.DrawHLine(0, 32, 127);    GLCD.DrawLine(0, 49, 127, 16);    }    else if((accx <= 95) && (accx > 90))    {       GLCD.ClearScreen();    GLCD.DrawHLine(0, 32, 127);    GLCD.DrawLine(0, 52, 127, 13);    }    else if((accx < 90) && (accx >= 85))    {       GLCD.ClearScreen();    GLCD.DrawHLine(0, 32, 127);    GLCD.DrawLine(0, 55, 127, 10);    }    else if((accx <= 85) && (accx > 80))    {      GLCD.ClearScreen();      GLCD.DrawHLine(0, 32, 127);      GLCD.DrawLine(0, 58, 127, 7);    }    else if ((accx < 80) && (accx >= 75))    {       GLCD.ClearScreen();    GLCD.DrawHLine(0, 32, 127);    GLCD.DrawLine(0, 63, 127, 0);    }                      loop_cnt++;    delay(1);}  I still left the draw line and clear screen in each else if.
 9 Forum 2005-2010 (read only) / Syntax & Programs / Re: GLCD Wii Tilt Code on: August 06, 2010, 02:21:58 pm Yes it does compile. Thanks guys for noticing. I was trying to get to if a value is greater than x but less than x do a glcd print. I'll rework it tonight and see what I get.@billI'll look for the example. I noticed in the examples you guys call a void ()  glcd clear.
 10 Forum 2005-2010 (read only) / Syntax & Programs / Re: GLCD Wii Tilt Code on: August 03, 2010, 06:23:24 pm Code:#include #include "fonts/Arial14.h"         // proportional font#include "fonts/SystemFont5x7.h"   // system font#include // initialize wire#include "nunchuck_funcs.h"int loop_cnt=0;byte accx;void setup(){  Serial.begin(19200);  nunchuck_setpowerpins();  nunchuck_init();  GLCD.Init(NON_INVERTED);  GLCD.ClearScreen();  GLCD.SelectFont(System5x7);  Serial.print("Wii nunchuck ready");  GLCD.DrawHLine(0, 32, 127);}void loop(){   if( loop_cnt > 100 ) {         loop_cnt = 0;        nunchuck_get_data();        accx  = nunchuck_accelx();        Serial.println((byte)accx,DEC);    if ((accx > 180) && (accx > 185)){  GLCD.ClearScreen();  GLCD.DrawHLine(0, 32, 127);  GLCD.DrawLine(0, 0, 127, 63);}else if(( accx < 180) && (accx > 175)){GLCD.ClearScreen();  GLCD.DrawHLine(0, 32, 127);  GLCD.DrawLine(0 , 3, 127, 60);   }else if ((accx < 175) && (accx > 170)){GLCD.ClearScreen();  GLCD.DrawHLine(0, 32, 127);GLCD.DrawLine(0, 6, 127, 57);}else if((accx < 170) && (accx > 165)){  GLCD.ClearScreen();  GLCD.DrawHLine(0, 32, 127);  GLCD.DrawLine(0, 9, 127, 54);   }  else if((accx < 165) && (accx > 160))  {      GLCD.ClearScreen();  GLCD.DrawHLine(0, 32, 127);  GLCD.DrawLine(0, 12, 127, 51);  }  else if((accx < 160) && (accx > 155))  {      GLCD.ClearScreen();  GLCD.DrawHLine(0, 32, 127);  GLCD.DrawLine(0, 15, 127, 48);  }  else if((accx < 155) && (accx > 150))    {GLCD.ClearScreen();  GLCD.DrawHLine(0, 32, 127);  GLCD.DrawLine(0, 18, 127, 45);    }    else if((accx < 150) && (accx > 145))    {    GLCD.ClearScreen();    GLCD.DrawHLine(0, 32, 127);    GLCD.DrawLine(0, 21, 127, 42);   }   else if((accx < 145) && (accx > 140))   {      GLCD.ClearScreen();    GLCD.DrawHLine(0, 32, 127);    GLCD.DrawLine(0, 24, 127, 39);   }   else if((accx < 140) && (accx > 135))   {    GLCD.ClearScreen();    GLCD.DrawHLine(0, 32, 127);    GLCD.DrawLine(0, 27, 127, 36);   }      else if((accx < 130) && (accx > 125))   {      GLCD.ClearScreen();    GLCD.DrawHLine(0, 32, 127);    GLCD.DrawLine(0, 32, 127, 32);   }       else if((accx < 125) && (accx > 120))       {        GLCD.ClearScreen();    GLCD.DrawHLine(0, 32, 127);    GLCD.DrawLine(0, 37, 127, 28);       }       else if((accx < 120) && (accx > 115))       {          GLCD.ClearScreen();    GLCD.DrawHLine(0, 32, 127);    GLCD.DrawLine(0, 40, 127, 25);       }    else if((accx < 115) && (accx > 110))     GLCD.ClearScreen();    GLCD.DrawHLine(0, 32, 127);    GLCD.DrawLine(0, 43, 127, 22);   }   else if((accx < 110) && (accx > 105))   {    GLCD.ClearScreen();    GLCD.DrawHLine(0, 32, 127);    GLCD.DrawLine(0, 46, 127, 19);   }   else if((accx < 105) && (accx > 100))   {         GLCD.ClearScreen();    GLCD.DrawHLine(0, 32, 127);    GLCD.DrawLine(0, 49, 127, 16);   }   else if((accx < 100) && (accx > 95))    {    GLCD.ClearScreen();    GLCD.DrawHLine(0, 32, 127);    GLCD.DrawLine(0, 52, 127, 13);    }    else if((accx < 95) && (accx > 90))    {       GLCD.ClearScreen();    GLCD.DrawHLine(0, 32, 127);    GLCD.DrawLine(0, 55, 127, 10);    }    else if((accx < 90) && (accx > 85))    {       GLCD.ClearScreen();    GLCD.DrawHLine(0, 32, 127);    GLCD.DrawLine(0, 58, 127, 7);    }    else if((accx < 85) && (accx > 80))    {      GLCD.ClearScreen();      GLCD.DrawHLine(0, 32, 127);      GLCD.DrawLine(0, 61, 127, 4);    }    else if ((accx < 80) && (accx > 75))    {       GLCD.ClearScreen();    GLCD.DrawHLine(0, 32, 127);    GLCD.DrawLine(0, 63, 127, 0);    }                      loop_cnt++;    delay(1);}Works until tilted to the left and some garbled lines and the serial monitor freezes.Looks like the data 75 to 125 hangs up. I took out 125 to 185 and does the same thing... :oShot a video:
 11 Forum 2005-2010 (read only) / Syntax & Programs / GLCD Wii Tilt Code on: August 03, 2010, 04:38:05 pm I started a new thread from this post:http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1279128237/45#45Code:#include #include "fonts/Arial14.h"         // proportional font#include "fonts/SystemFont5x7.h"   // system font#include // initialize wire#include "nunchuck_funcs.h"int loop_cnt=0;byte accx;void setup(){  Serial.begin(19200);  nunchuck_setpowerpins();  nunchuck_init();  GLCD.Init(NON_INVERTED);  GLCD.ClearScreen();  GLCD.SelectFont(System5x7);  Serial.print("Wii nunchuck ready");  GLCD.DrawHLine(0, 32, 127);}void loop(){   if( loop_cnt > 100 ) {         loop_cnt = 0;        nunchuck_get_data();        accx  = nunchuck_accelx();        Serial.println((byte)accx,DEC);    if ( accx > 180){  GLCD.ClearScreen();  GLCD.DrawHLine(0, 32, 127);  GLCD.DrawLine(0, 63, 127, 0);}else if ( accx > 130){GLCD.ClearScreen();  GLCD.DrawHLine(0, 32, 127);  GLCD.DrawLine(0 , 32, 64, 0);   }else if ( accx < 130){GLCD.ClearScreen();  GLCD.DrawHLine(0, 32, 127);GLCD.DrawLine(0, 0, 127, 0);   }             }    loop_cnt++;    delay(1);}It's working but I need to get it fine tuned.I prefer the math method as its easiest for me to use.Based on tilt detection from a value of 73 to 185 I'm trying to make a tilt gauge. I could use alot of the else if statements but thats going to be alot of code .Whenever read 73 to 80 id implement a GLCD.DrawLine(0, 63, 127, 0)from 80 to 85 id do a GLCD.DrawLine(0, 58, 127, 5) all the way till I get past a value of 130 and it'd go the oppposite way.Edit: New code working goodCode:#include #include "fonts/Arial14.h"         // proportional font#include "fonts/SystemFont5x7.h"   // system font#include // initialize wire#include "nunchuck_funcs.h"int loop_cnt=0;byte accx;void setup(){  Serial.begin(19200);  nunchuck_setpowerpins();  nunchuck_init();  GLCD.Init(NON_INVERTED);  GLCD.ClearScreen();  GLCD.SelectFont(System5x7);  Serial.print("Wii nunchuck ready");  GLCD.DrawHLine(0, 32, 127);}void loop(){   if( loop_cnt > 100 ) {         loop_cnt = 0;        nunchuck_get_data();        accx  = nunchuck_accelx();        Serial.println((byte)accx,DEC);    if ( accx > 180){  GLCD.ClearScreen();  GLCD.DrawHLine(0, 32, 127);  GLCD.DrawLine(0, 63, 127, 0);}else if(( accx < 179) && (accx > 170)){GLCD.ClearScreen();  GLCD.DrawHLine(0, 32, 127);  GLCD.DrawLine(0 , 59, 127, 5);   }else if ((accx < 169) && (accx > 160)){GLCD.ClearScreen();  GLCD.DrawHLine(0, 32, 127);GLCD.DrawLine(0, 54, 127, 10);}else if((accx < 159) && (accx > 150)){  GLCD.ClearScreen();  GLCD.DrawHLine(0, 32, 127);  GLCD.DrawLine(0, 49, 127, 15);   }  else if((accx < 149) && (accx > 140))  {      GLCD.ClearScreen();  GLCD.DrawHLine(0, 32, 127);  GLCD.DrawLine(0, 45, 127, 20);  }  else if((accx < 139) && (accx > 130))  {      GLCD.ClearScreen();  GLCD.DrawHLine(0, 32, 127);  GLCD.DrawLine(0, 41, 127, 25);  }  else if((accx < 129) && (accx > 120))    {GLCD.ClearScreen();  GLCD.DrawHLine(0, 32, 127);  GLCD.DrawLine(0, 32, 127, 32);    }               }    loop_cnt++;    delay(1);}
 12 Forum 2005-2010 (read only) / Syntax & Programs / Re: Trouble with code on: March 09, 2010, 04:37:18 pm I was missing a }
 13 Forum 2005-2010 (read only) / Syntax & Programs / Re: Trouble with code on: March 09, 2010, 04:26:02 pm Yes it uploads fine... Problem is when hits button 4 it wont physically do whats in the code...:Code:if (lightMode == 4) {      analogWrite(redPin, 255);      delay(500);      analogWrite(greenPin, 255);      delay(500);      analogWrite(redPin, 100);      analogWrite(greenPin, 180);      delay(500);      analogWrite(redPin, 0);      analogWrite(greenPin, 255);      analogWrite(bluePin, 255);      delay(500);      analogWrite(redPin, 0);      analogWrite(bluePin, 100);      analogWrite(greenPin, 100);      delay(500);      analogWrite(redPin, 255);      analogWrite(greenPin, 255);      analogWrite(bluePin, 0);      delay(500);      analogWrite(redPin, 0);      analogWrite(greenPin, 170);      analogWrite(bluePin, 80);
 14 Forum 2005-2010 (read only) / Syntax & Programs / Trouble with code on: March 09, 2010, 03:09:37 pm Code:// RGB Lightint switchPin = 2;              int redPin = 5;int greenPin = 6;int bluePin = 3;int val;                        int val2;                       int buttonState;              int lightMode = 0;           void setup() {  pinMode(switchPin, INPUT);      pinMode(redPin, OUTPUT);  pinMode(greenPin, OUTPUT);  pinMode(bluePin, OUTPUT);    Serial.begin(9600);            buttonState = digitalRead(switchPin);   }void loop(){  val = digitalRead(switchPin);        delay(10);                           val2 = digitalRead(switchPin);      if (val == val2) {                     if (val != buttonState) {                if (val == LOW) {                     if (lightMode == 0) {                    lightMode = 1;                     } else {          if (lightMode == 1) {                   lightMode = 2;                      } else {            if (lightMode == 2) {                    lightMode = 3;                     } else {           if (lightMode == 3) {             lightMode = 4;            }   else {                 lightMode = 0;                        }                  }          }          }              }    }    buttonState = val;            }  //   if (lightMode == 0) {analogWrite(redPin, 0);analogWrite(greenPin, 0);analogWrite(bluePin, 0);  }  if (lightMode == 1) {     analogWrite(redPin, 255);    analogWrite(bluePin, 255);    analogWrite(greenPin, 0);  }  if (lightMode == 2) {     analogWrite(redPin, 255);    analogWrite(bluePin, 0);    analogWrite(greenPin, 255);          }  if (lightMode == 3)  {     analogWrite(redPin, 0);    analogWrite(greenPin, 255);    analogWrite(bluePin, 255);          if (lightMode == 4) {    analogWrite(redPin, 255);    delay(500);    analogWrite(greenPin, 255);    delay(500);    analogWrite(redPin, 100);    analogWrite(greenPin, 180);    delay(500);    analogWrite(redPin, 0);    analogWrite(greenPin, 255);    analogWrite(bluePin, 255);    delay(500);    analogWrite(redPin, 0);    analogWrite(bluePin, 100);    analogWrite(greenPin, 100);    delay(500);    analogWrite(redPin, 255);    analogWrite(greenPin, 255);    analogWrite(bluePin, 0);    delay(500);    analogWrite(redPin, 0);    analogWrite(greenPin, 170);    analogWrite(bluePin, 80);         }  }}  Works fine till I press the button the 4th time to the delayed analogWrite.I adapted from lady ada's code.
 15 Forum 2005-2010 (read only) / Syntax & Programs / Re: Map() Function - am i missing something? on: February 28, 2010, 10:52:01 pm Quotedo you think changing the D9 to D1 would help?give it a try see what happens
 Pages: [1] 2 3 ... 28