Download Print this page

Seeed Grove Beginner Kit User Manual page 23

For arduino
Hide thumbs Also See for Grove Beginner Kit:

Advertisement

Grove Beginner Kit For Arduino®
Software Code
Open Arduino IDE.
Copy the following code, click Verify to check for syntax errors. Verify that there are no
errors, and you can upload the code.
//Rotary controls LED
int
rotaryPin = A0;
int
ledPin = 4;
int
rotaryValue = 0;
ry
void
setup() {
// declare the ledPin as an OUTPUT:
pinMode(ledPin, OUTPUT);
}
void
loop() {
// read the value from the sensor:
rotaryValue = analogRead(rotaryPin);
// turn the ledPin on
digitalWrite(ledPin, HIGH);
// stop the program for <sensorValue> milliseconds:
delay(rotaryValue);
// turn the ledPin off:
digitalWrite(ledPin, LOW);
// stop the program for for <sensorValue> milliseconds:
delay(rotaryValue);
}
// select the input pin for the rotary
// select the pin for the LED
// variable to store the value coming from the rota
22

Advertisement

loading
Need help?

Need help?

Do you have a question about the Grove Beginner Kit and is the answer not in the manual?