Senior Design Project Help

hgmjr

Joined Jan 28, 2005
9,027
Well, it is up to you but since it is pretty easy to change just the limits, maybe you can do that for the moment. Once it is working you can refine it anyway you like.

Be sure to change the code to my second suggested program.

hgmjr
 

Thread Starter

ripcus10

Joined Apr 13, 2012
56
SUCCESS!!!!!!!!!!!!!!!! It finally reads in all directions and is off when at rest!! Here is the code that i used to finally get it to work
Rich (BB code):
  {digitalWrite(relaypin, LOW);}
  if(analogRead(xpin)>431)
  { digitalWrite(relaypin, HIGH); }
  else if(analogRead(xpin)<243)
  { digitalWrite(relaypin, HIGH); }
  else{digitalWrite(relaypin, LOW);}
  if(analogRead(ypin)>431)
  { digitalWrite(relaypin, HIGH); }
  else if(analogRead(ypin)<243)
  { digitalWrite(relaypin, HIGH); }
  else{digitalWrite(relaypin, LOW);}
  if (analogRead(zpin)>431)
  { digitalWrite(relaypin, HIGH); }
  else if(analogRead(zpin)<243)
  { digitalWrite(relaypin, HIGH); }
  else{digitalWrite(relaypin, LOW);}
  // delay before next reading:
  delay(100);
  
}
It is what Chrisw1990 and I were messing around with before but with the limits that you said would work!!
 

Thread Starter

ripcus10

Joined Apr 13, 2012
56
Thank you hgmjr and chrisw1990 for helping me get this worked out. I know it had to be frustrating to work with me at times but thank you for sticking with me!! If it wasn't for the two of you I would probably be off in a corner crying somewhere. Thanks a ton for all your help!!
 

chrisw1990

Joined Oct 22, 2011
551
haha no problem! like hgmjr said, persistence is key, it will be a valuable asset to you if you can stick at things like you have with this coding :)
 
Top