Example Code for Arduino

Last revision 2025/12/25

Sample Code

    void setup()
    {
      Serial.begin(9600); // open serial port, set the baud rate to 9600 bps
    }
    void loop()
    {
          int val;
          val=analogRead(0);      //connect sensor to Analog 0
          Serial.println(val);    //print the value to serial
          delay(100);
    }

Was this article helpful?

ON THIS PAGE

TOP