hdxn
March 19, 2017, 11:44pm
1
Hi guys,
I am really new at arduino programming. Doing a project and want to control 4 vibration motors from one arduino (pins 3;4;5;6;). Is it possible using this code ? and how to multiply it ?
const int motorPin = 3;
void setup()
{
pinMode (motorPin, OUTPUT) ;
}
void loop()
{
digitalWrite (motorPin, HIGH) ;
delay(1000) ;
digitalWrite (motorPin, LOW) ;
delay(1000) ;
}
First you need to understand how to get rid of the delay() calls and replace them with non-blocking timing.
It might sound complicated.
In fact it's a commonly used pattern.
There's a nice example included in the IDE. IIRC it's called Blink without delay.
Also make extensive use of the auto-indent feature of the Arduino IDE. Indentation makes code clearer and bugs less likely
const int motorPin = 3;
void setup()
{
pinMode (motorPin, OUTPUT) ;
}
void loop()
{
digitalWrite (motorPin, HIGH) ;
delay(1000) ;
digitalWrite (motorPin, LOW) ;
delay(1000) ;
}
system
March 20, 2017, 10:31am
4
Is it possible using this code ?
No. You need to add a lot more code.
and how to multiply it ?
Use arrays and for loops to "multiply" it.