-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This simple project created by using 128x64 OLED 0.96" IIC/I2C Serial and arduino uno if you want more information or schematics to this diagram please visit http://circuitfreak.net/index.php/2015/05/05/arduino-oled-voltage-meter/
- Loading branch information
0 parents
commit 49b6b7f
Showing
1 changed file
with
54 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/*code by Neranjan Walakulpola | ||
for more help and diagram visit | ||
http://www.http://circuitfreak.net/index.php/2015/05/05/arduino-oled-voltage-meter/ | ||
*/ | ||
|
||
#include <SPI.h> | ||
#include <Wire.h> | ||
#include <Adafruit_GFX.h> | ||
#include <Adafruit_SSD1306.h> | ||
|
||
#define OLED_RESET 4 | ||
Adafruit_SSD1306 display(OLED_RESET); | ||
|
||
#if (SSD1306_LCDHEIGHT != 64) | ||
#error("Height incorrect, please fix Adafruit_SSD1306.h!"); | ||
#endif | ||
|
||
void setup() { | ||
|
||
|
||
// Set up the display | ||
display.begin(SSD1306_SWITCHCAPVCC, 0x3C); // Initialize with the I2C addr 0x3D if not working use 0x3C (for the 128x64) | ||
display.setTextColor(WHITE); | ||
|
||
|
||
} | ||
void loop(){ | ||
|
||
// draw scrolling text | ||
delay(1); | ||
display.clearDisplay(); | ||
|
||
// text display tests | ||
display.setTextSize(1); | ||
display.setTextColor(WHITE); | ||
display.setCursor(0,0); | ||
display.println("Analog Read V1.0"); | ||
display.setTextColor(BLACK, WHITE); | ||
display.println(); | ||
display.println("A0"); | ||
display.setTextSize(1); | ||
display.setTextColor(WHITE); | ||
display.println(); | ||
display.setTextSize(2); | ||
display.setTextSize(2); | ||
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: | ||
display.print(voltage); display.println("V"); | ||
display.display(); | ||
|
||
} | ||
|