Testing battery readings to display on screen.
This commit is contained in:
@@ -21,12 +21,13 @@ Adafruit_SSD1306 display(OLED_RESET);
|
||||
#define OFF 1 // OFF means pin is on VCC
|
||||
|
||||
// Assign switches and led's to arduino pins
|
||||
#define UP 2 // Switch 1 will be function UP connected to arduino pin 2
|
||||
#define UP 2 // Switch 1 will be function UP connected to arduino PD 2
|
||||
#define OK 3 // Switch 2 will be function OK connected to arduino pin 3
|
||||
#define DOWN 4 // Switch 3 will be function DOWN connected to arduino pin 4
|
||||
#define CANCEL 5 // Switch 4 will be function CANCEL connected to arduino pin 5
|
||||
#define led1 9 // Led 1 connected to arduino pin 9
|
||||
#define led2 10 // Led 2 connected to arduino pin 10
|
||||
#define batt 17 // Battery plus connected to arduino pin 17
|
||||
|
||||
// Macros to read the switchs
|
||||
#define rUP digitalRead(UP) // Read button UP state
|
||||
@@ -56,6 +57,7 @@ int UP_state = OFF; // Holds state for UP, either ON or OFF
|
||||
int OK_state = OFF; // Holds state for OK, either ON or OFF
|
||||
int DOWN_state = OFF; // Holds state for DOWN, either ON or OFF
|
||||
int CANCEL_state = OFF; // Holds state for CANCEL, either ON or OFF
|
||||
int batt_val = 0; // Holds the value of battery voltage
|
||||
|
||||
|
||||
// Create SoftwareSerial object and designate pins
|
||||
@@ -126,7 +128,7 @@ void setup() { // BEGIN SETUP ------------------------------------
|
||||
// Timer compare interrupt service routine --------------------------
|
||||
ISR(TIMER1_COMPA_vect) // Here we chose between the blinker sequence
|
||||
{ // or to show the temperature on the LEDs
|
||||
|
||||
/*
|
||||
if (!rUP) {
|
||||
if (menuState == 1) {
|
||||
menuState = 1;
|
||||
@@ -197,7 +199,7 @@ ISR(TIMER1_COMPA_vect) // Here we chose between the blinker sequence
|
||||
}
|
||||
while (!rCANCEL); // Check if button is still pressed do nothing
|
||||
}
|
||||
|
||||
*/
|
||||
}
|
||||
// -------------------------------------------------------------------
|
||||
|
||||
@@ -206,6 +208,31 @@ ISR(TIMER1_COMPA_vect) // Here we chose between the blinker sequence
|
||||
void loop() {
|
||||
//digitalWrite(led2, !digitalRead(led2)); // toggle state
|
||||
|
||||
|
||||
|
||||
|
||||
batt_val = analogRead(batt);
|
||||
|
||||
display.drawRect(0, 8, 168, 24, BLACK);
|
||||
display.display();
|
||||
display.clearDisplay();
|
||||
display.setTextSize(1);
|
||||
display.setTextColor(WHITE);
|
||||
display.setCursor(50,18);
|
||||
display.println(batt_val);
|
||||
batt_icon();
|
||||
display.display();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
if (menuState == 1) {
|
||||
one();
|
||||
}
|
||||
@@ -230,7 +257,7 @@ void loop() {
|
||||
else {
|
||||
one();
|
||||
}
|
||||
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user