Galileo code for DC motor speed control
Open the IDE and then enter the following code:
This code sends basic commands to the Galileo to control the speed of the motor. Here are the details:
int motorPin = 11;
:- This sets digital I/O pin 11 to the control pin you'll be using.void setup()
:– The setup function executes once you set up your Galileo.pinMode(motorPin, OUTPUT);
:- This sets this pin to function as an output pin.Serial.begin(9600);
:- This starts the serial port with a baud rate of 9600.Serial.println("Set Speed 0 - 255");
:- This prints the line "Set Speed 0 – 255".void loop()
:– This loop is performed over and over again on the Galileo.if (Serial.available())
:– If there is a serial input date on the serial port, then do the following statements.int speed = Serial.parseInt();
:- This brings in the data as an integer.Serial.println("Speed");
:- This prints the line "Speed".Serial.print(speed);
:- This prints the value input from the serial port.Serial.println(" " );
:- This finishes...