Created
July 25, 2017 03:44
-
-
Save IdrisCytron/4bac83fa84ce9abec3c6b5a1f6700c4b to your computer and use it in GitHub Desktop.
IR Distance Click Arduino examples code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void setup() | |
{ | |
// IR Distance Click OUT pin is connected to pin A0 | |
// Set A0 as input | |
pinMode(A0, INPUT); | |
// Initialize Serial for debug purpose | |
Serial.begin(9600); | |
delay(1000); // Put some delay | |
} | |
void loop() | |
{ | |
int adc = analogRead(A0); // Read analog input from pin A0 | |
float voltage = adc * 0.00488; // Change ADC to voltage | |
// Print distance information to serial | |
Serial.print("ADC: "); | |
Serial.print(adc); | |
if (adc < 99) Serial.print('\t'); | |
Serial.print("\tVoltage: "); | |
Serial.println(voltage); | |
delay(100); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment