Hi all,
I was really excited about making a stupid trick game this week. Unfortunately I didn’t get that far. I could not get my servo to behave. What a frustrating weekend (I almost put my Arduino in the freezer overnight)…
Heres what I tried:
1) Servo Demo with Potentiometer (code from Examples> Arduino) (then 2 codes from the web that still produced no results)
Produced no values in serial print to indicate the potentiometer was working (Also tried putting in a photoresistor, did not seem to do anything either)
2) Servo Arduino Example Mood Indicator (code from Starter Kit > Servo Mood)
Got a response from serial print but still couldn’t control my Servo
3) Button Controlled
Could get this to work, but adding another button didn’t work. (note, not my code, lost the original source but I can find it again!)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
#include <Servo.h> int button1 = 4; //button pin, connect to ground to move servo int press1 = 0; Servo servo1; void setup() { pinMode(button1, INPUT); servo1.attach(7); digitalWrite(4, HIGH); } void loop() { press1 = digitalRead(button1); if (press1 == LOW) { servo1.write(180); } else { servo1.write(0); } } |
4) Simple Rotations
Worked, but odd clicking sounds and humming made me wonder if there is a problem with the Servo
Eventually I just figured I would bring it in and switch to playing with the LED light instead.
(Still determined to make a stupid trick though!)