HI i am new to this forum. I have been trying to power a Nano with 12 Volts and to light 7 5 volt LEDs and run a 12 volt motor in 10 sec intervals here is the code i have been using.`
/*
Motor and LED controller
*/
// constants won't change. They're used here to set pin numbers:
const int buttonPin = 10; // the number of the pushbutton pin
// variables will change:
int buttonState = 0; // variable for reading the pushbutton status
// the setup function runs once when you press reset or power the board
void setup() {
// initialize digital pins
pinMode(2, OUTPUT); // Motor control
pinMode(3, OUTPUT); // LED 1
pinMode(4, OUTPUT); // LED 2
pinMode(5, OUTPUT); // LED 3
pinMode(6, OUTPUT); // LED 4
pinMode(7, OUTPUT); // LED 5
pinMode(8, OUTPUT); // LED 6
pinMode(9, OUTPUT); // LED 7
pinMode(10, INPUT); // Button pin
}
// the loop function runs over and over again forever
void loop() {
// read the state of the pushbutton value:
buttonState = digitalRead(buttonPin);
// check if the pushbutton is pressed. If it is, the buttonState is HIGH:
if (buttonState == HIGH) {
// start cycle
digitalWrite(2, HIGH); // turn the Motor on
delay(10000); // wait for a 10 seconds
digitalWrite(2, LOW); // turn the Motor off
digitalWrite(3, HIGH); // turn the LED 1 ON
delay(1000); // wait for 1 second
digitalWrite(2, HIGH); // turn the Motor on
delay(10000); // wait for a 10 seconds
digitalWrite(2, LOW); // turn the Motor off
digitalWrite(4, HIGH); // turn the LED 2 ON
delay(1000); // wait for 1 second
digitalWrite(2, HIGH); // turn the Motor on
delay(10000); // wait for a 10 seconds
digitalWrite(2, LOW); // turn the Motor off
digitalWrite(5, HIGH); // turn the LED 3 ON
delay(1000); // wait for 1 second
digitalWrite(2, HIGH); // turn the Motor on
delay(10000); // wait for a 10 seconds
digitalWrite(2, LOW); // turn the Motor off
digitalWrite(6, HIGH); // turn the LED 4 ON
delay(1000); // wait for 1 second
digitalWrite(2, HIGH); // turn the Motor on
delay(10000); // wait for a 10 seconds
digitalWrite(2, LOW); // turn the Motor off
digitalWrite(7, HIGH); // turn the LED 5 ON
delay(1000); // wait for 1 second
digitalWrite(2, HIGH); // turn the Motor on
delay(10000); // wait for a 10 seconds
digitalWrite(2, LOW); // turn the Motor off
digitalWrite(8, HIGH); // turn the LED 6 ON
delay(1000); // wait for 1 second
digitalWrite(2, HIGH); // turn the Motor on
delay(10000); // wait for a 10 seconds
digitalWrite(2, LOW); // turn the Motor off
digitalWrite(9, HIGH); // turn the LED 7 ON
delay(10000);
// Reset cycle, wait for button activation
delay(10000); // wait for 10 second
} else {
// turn pins off:
digitalWrite(2, LOW); // turn the motor off
digitalWrite(3, LOW); // turn the LED 1 off
digitalWrite(4, LOW); // turn the LED 2 off
digitalWrite(5, LOW); // turn the LED 3 off
digitalWrite(6, LOW); // turn the LED 4 off
digitalWrite(7, LOW); // turn the LED 5 off
digitalWrite(8, LOW); // turn the LED 6 off
digitalWrite(9, LOW); // turn the LED 7 off
}
}`
The trouble i am having is what do i need to control the mortor