1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00
RIOT/tests/sys_arduino_analog/arduino-test.sketch
Alexandre Abadie 779e25bc7d
tests/sys_arduino_analog: add test application
The goal of this application is to test the analogRead and analogWrite Arduino function
2019-11-15 17:51:45 +01:00

16 lines
599 B
Plaintext

// Example sketch given in analogWrite documentation
// https://www.arduino.cc/reference/en/language/functions/analog-io/analogwrite/
int ledPin = LED_PIN; // LED connected to digital pin 3 by default
int analogPin = 1; // potentiometer connected to analog pin 1
int val = 0; // variable to store the read value
void setup() {
pinMode(ledPin, OUTPUT); // sets the pin as output
}
void loop() {
val = analogRead(analogPin); // read the input pin
analogWrite(ledPin, val / 4); // analogRead values go from 0 to 1023, analogWrite values from 0 to 255
}