How to read all analog sensors on arduino

Поделиться
HTML-код
  • Опубликовано: 7 ноя 2024
  • //This code will help you to read all analog sensors on every microprocessors.
    you can also follow us on website www.shwatech.o...
    and also on gihub: github account: github.com/shw...
    this is the code to do it :
    int analogpin = A0;
    int readings;
    int readingsInPercentages;
    void setup(){
    Serial.begin(9600);
    pinMode(analogpin, INPUT);
    }
    void loop(){
    readings = analogRead(analogpin);
    readingsInPercentages = map(readings, 0, 1024, 100, 0);
    Serial.print("the percentage reading is ");
    Serial.println(readingsInPercentages);
    Serial.print(" %");
    }
    IN THE COMMENT BELLOW I NEED TO KNOW WHAT WOULD HAPPEN IF WE HAD PUT float analogpin = A0; instead of int analogpin = A0;

Комментарии • 1