2、读取模拟电压 - Read Analog Voltage Reads an analog input and prints the voltage to the Serial Monitor. 读取模拟输入并打印电压值到串口监视器。 This example shows you how to read an analog input on analog pin 0, convert the values from analogRead() into voltage, and print it out to the...
void loop() { // read the input on analog pin 0: int sensorValue =analogRead(A0); // Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V): float voltage = sensorValue * (5.0 / 1023.0); // print out the value you read: Serial.println(voltage); } 火...
void loop() { // read the input on analog pin 0: int sensorValue = analogRead(A0); // Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V): float voltage = sensorValue * (5.0 / 1023.0); // print out the value you read: Serial.println(voltage); } [...
}//the loop routine runs over and over again forever:voidloop() {//read the input on analog pin 0:intsensorValue =analogRead(A0);//Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V):floatvoltage = sensorValue * (5.0/1023.0);//print out the value you r...
格瑞图:Arduino-0007-内置示例-读取模拟电压 Read Analog Voltage 格瑞图:Arduino-0008-内置示例-非延迟闪烁 Blink Without Delay 格瑞图:Arduino-0009-内置示例-按钮 Button 格瑞图:Arduino-0010-内置示例-去抖 Debounce 格瑞图:Arduino-0011-内置示例-数字输入上拉 DigitalInputPullup ...
unsigned int readings[numReadings]; // the readings from the analog input byte index = 0; // the index of the current reading unsigned long AnalogValueTotal = 0; // the running total unsigned int AnalogAverage = 0,averageVoltage=0; // the average ...
intsensorValue=analogRead(pin_zhuodu);//read theinputon analog pin0: floatTU=sensorValue*(5.0/1024.0);//Convert the analog reading (which goesfrom0-1023) to a voltage (0-5V): TU_calibration=-0.0192*(temp_data-25)+TU; TU_value=-865.68*TU_calibration+K_Value; ...
These pins correspond to analog pins A4 (SDA) and A5 (SCL) on the Arduino Uno. Arduino ADC Specification Parameter Arduino Uno/Nano Voltage Supply (Vs) 1V8 ~ 5V5 Interface Built in Resolution 10 bit Absolute Accuracy(Including INL, DNL, ...
int IRpin = 0; // analog pin for reading the IR sensor void setup() { Serial.begin(9600); // start the serial port } void loop() { float volts = analogRead(IRpin) * 0.0048828125; // value from sensor * (5/1024) - if running 3.3.volts then change 5 to 3.3 ...
you will generally be OK with a value between 1K and 10K. The light level on the sensor will change the voltage level on analog pin 0. TheanalogReadcommand (seeChapter 6) provides a value that ranges from around 200 when the sensor is dark to 800 or so when it is very bright (the ...