This is a demonstration of a Uno reading adc and displaying the result graphically on a 128X64 oled usin GLCD library. Here is a short youtube video. https://youtu.be/iVNaNDmBrE0 ;display repetative wave forms on 128x64 oled i2c display
#chip mega328p,16 #option explicit #include <UNO_mega328p.h> #include <glcd.h> #define HI2C_BAUD_RATE 400 #define HI2C_DATA HI2CMode Master #define GLCD_TYPE GLCD_TYPE_SSD1306 #define GLCD_I2C_Address 0x78 #define ADSpeed LowSpeed ; dir portc.0 in dim volt as byte dim ptr1 as Byte dim ptr2 as byte dim buffer1 (32) dim buffer2 (32) dim xpos_new as byte dim ypos_new as byte dim xpos_old as byte dim ypos_old as byte dim xpos1_new as byte dim ypos1_new as byte dim xpos1_old as byte dim ypos1_old as byte ; for ptr1=0 to 31 ;read 32 samples volt = READAD (an0) buffer1 (ptr1)=volt/4 buffer2 (ptr1)=volt/4 next ptr1 ; GLCDCLS main: ptr1=0 ptr2=0 do until ptr1>30 ypos_old=buffer2 (ptr1) ;old data ypos_new=buffer2 (ptr1+1) xpos_old=ptr2 xpos_new=ptr2+4 ; ypos1_old=buffer1 (ptr1) ;new data ypos1_new=buffer1 (ptr1+1) xpos1_old=ptr2 xpos1_new=ptr2+4 ; line xpos_old,ypos_old,xpos_new,ypos_new,0 ;erase last data line xpos1_old,ypos1_old,xpos1_new,ypos1_new,1 ;draw new data ; ptr1=ptr1+1 ;data pointer ptr2=ptr2+4 ;x position for start and end line x positions loop ; for ptr1=0 to 31 ;get new samples volt = READAD (an0) repeat 2 ;scale 256 bit sample to 64 pixels ie divide by 4 set c off rotate volt right End Repeat buffer2 (ptr1)=buffer1 (ptr1) ;new data to old data buffer1 (ptr1)=volt ;update new data next ptr1 ; goto main
Log in to post a comment.
This is a demonstration of a Uno reading adc and displaying the result graphically on a 128X64 oled usin GLCD library. Here is a short youtube video. https://youtu.be/iVNaNDmBrE0
;display repetative wave forms on 128x64 oled i2c display
Last edit: William Roth 2017-03-11