[Arduino Step by Step 2017: Getting Started]
**Test Sketches**
Blinking:
void setup() { pinMode(LED_BUILTIN, OUTPUT); } void loop() { digitalWrite(LED_BUILTIN, HIGH); delay(250); digitalWrite(LED_BUILTIN, LOW); delay(250); }
Reading from Potentiometer:
void setup() { // initialize serial communication at 9600 bits per second: Serial.begin(9600); } void loop() { // Read the potentiometer on analog input #0 int sensorValue = analogRead(A0); // print the value Serial.println(sensorValue); // wait delay(1000); }
Use Potentiometer to dim LED:
const int LED_PIN = 11; void setup() { // initialize serial communication at 9600 bits per second: Serial.begin(9600); pinMode(LED_PIN, OUTPUT); } void loop() { // Read the potentiometer on analog input #0 int sensorValue = analogRead(A0); // Use the sensor input to manipulate the delay int iDelay = sensorValue / 1000.0f * 5; digitalWrite(LED_PIN, HIGH); delay(iDelay); digitalWrite(LED_PIN, LOW); delay(1); }