I have just started to use an arduino so i am not very familiar with the codes.
My main goal is to run a dc motor at a controlled rate (eg.every 10seconds) using an arduino and other components such as resistors and diodes.
My main problem is that im not sure of the codes needed to run the motor at a controlled rate.i have searched google for the codes but im unable to find the ones related to my work.
https://makezine.com/projects/control-a-5v-motor-with-the-arduino/-------this is the website i refered to to run the motor
This is the code i used to run the motor:
int motorPin = 3;
while (! Serial);
Serial.println(“Speed 0 to 255”);
int speed = Serial.parseInt();
if (speed >= 0 && speed <= 255) // This if statement will prevent the user from entering invalid motor speeds
Any suggestions to improve our circuit and codes?