Programming Examples
Arduino program using any one development board (E.g., Arduino or Raspberry Pi) to read data from a sensor

Write a program using any one development board (E.g., Arduino or Raspberry Pi) to read data from a sensor. Experiment with both analog and digital sensors.
Solution#define POT_PIN A0
#define BUTTON_PIN 2
void setup() {
Serial.begin(9600);
pinMode(BUTTON_PIN, INPUT_PULLUP);
}
void loop() {
int potValue = analogRead(POT_PIN); // Read analog sensor
int buttonState = digitalRead(BUTTON_PIN); // Read digital sensor
Serial.print("Potentiometer Value: ");
Serial.print(potValue);
Serial.print(" | Button State: ");
if (buttonState == HIGH)
Serial.println("Pressed");
else
Serial.println("Not Pressed");
delay(1000);
}
▶ RUN Output/ Explanation: 