Guys, i`m trying to figure out how to construct this sketch to have progress bar related to pot.
My problem at the moment is that the code work only in left top corner and "0" draw full box, around "950"erase it to one line and everything above draw 15 pixel 64 pixel block.
Any ideas??
#include "U8glib.h"
U8GLIB_LM6059 u8g(8, 9, 5, 7, 6);
//▼Sensor Inputs
int sensor1 = A0;
//▼RGB
int redPin = 12;
int greenPin = 11;
int bluePin = 10;
void setup(void) {
Serial.begin(9600);
pinMode(redPin, OUTPUT);
pinMode(greenPin, OUTPUT);
pinMode(bluePin, OUTPUT);
//▼Pressure Sensors
pinMode(sensor1, INPUT);
}
void loop(void) {
uint16_t adc;
// read ADC value from pin 0. Range is 0..1023
adc = analogRead(sensor1);
Serial.println(adc);
// convert ADC value to 0..15
adc = adc/64;
// picture loop
u8g.firstPage();
do {
u8g.drawBox(0, adc, 15, 15-adc);
} while( u8g.nextPage() );
}
from your base up to a height determined by the sensor, draw this solid in the foreground colour.
from the height determined by the sensor to the height given by the full range of the sensor. Draw this solid in the background colour.
Keep a record of the last sensor value you drew and only redraw the two boxes when it has changed by a certain small ammount. This prevents flickering on the display.
The abs is in the right place but the 'if' only works on the first instruction after it. You need to put all the conditional code inside braces { your conditional code }