/* * Copyright (C) 2021 - Cuautli Garcia - All Rights Reserved * * FabAcademy * * Version 1.0 * Autor: Cuautli Garcia - cuautli.garciaa@gmail.com * */ //Variable definition #define btnPin 26 //GPIO number for the digital input #define Pot 34 //GPIO number for the analog input int state = 0; //Variable to save the state of the digital input float ana = 0; //Variable to save the state of the analog input void setup() { Serial.begin(115200); //Initialize the serial communication pinMode(btnPin, INPUT);//Set the btnPin as INPUT pinMode(Pot, INPUT); //Set the Pot pin as INPUT } void loop() { //Read the digital input and multiply it by 5 to get 0 or 5 state = digitalRead(btnPin)*5; //Read the analog input and divide it by 819.0 to get 5 at 4095 //Since the ESP has 12-bit ADC's ana = analogRead (Pot)/819.0; Serial.print(ana); //Print the analogic reading Serial.print(","); //Print a comma to separate the graphs Serial.println(state);//Print the digital reading delay(200); //Delay of 200 ms }