I have tried and tried to use this code with an Arduino Nano and with an Uno. I have uploaded this sketch to both and the LEDs flash and it completes the upload, so it appears the sketch was accepted. I hook up the servo to pin 5, and the push buttons to pins 6 & 7, but nothing. At power up, the servo seems to center, but nothing happens when I push the buttons.
I get an error during compile that states "Arduino ' " ' is not a valid category", and then it says it's rebuilding the entire sketch, after which it says sketch compiled and used xxx amount of space etc.
Any ideas why this happens?
Thanks for any guidance.
The servo is powered by a seperate 5vdc power supply. The Arduino is powered by 4.8vdc to the 5v pin.
The push buttons are wired to pins 6 & 7 with the common going to board ground. This is supposed to be a sketch that will move a servo in one direction as long as the button is pressed or until the servo reaches 180 degrees. The same with the other push button in the opposite direction.
Thank you for your reply.
Guitartexan:
The servo is powered by a seperate 5vdc power supply. The Arduino is powered by 4.8vdc to the 5v pin.
The push buttons are wired to pins 6 & 7 with the common going to board ground. This is supposed to be a sketch that will move a servo in one direction as long as the button is pressed or until the servo reaches 180 degrees. The same with the other push button in the opposite direction.
Thank you for your reply.
Have you connected the grounds?
Are the buttons four pin tact switches? If so, are they in the correct orientation?
I did not connect the ground for the servo with ground of the Arduino. So I should connect the grounds of the two power supplies together, correct?
I am using a momentary pushbutton and are not four pin tact switches. I have negative/ground as common of the switch and pin 6 & 7 as the signal side of the push buttons.
Guitartexan:
I did not connect the ground for the servo with ground of the Arduino. So I should connect the grounds of the two power supplies together, correct?
Alright. I can rule that out. I connected the grounds together to the Arduino ground and this had no effect. I do not have resistors on the push buttons. I am using ground as the common for the buttons. Is this correct? This is how it is shown in the schematic diagram.
Thanks.
The one that you haven't shared? The one that you haven't posted a photo of your wiring actually implementing?
The schematic is wrong (or unnecessarily complicated, which, to programmers, means the same as wrong). Use the internal pullup resistors (pinMode(thePin, INPUT_PULLUP); ) and connect one leg to thePin and one leg to ground.
Hi,
Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?
Also a picture of your project would help thanks.