KRITSADA

ATX2 Read Average ADC0 show On Bargraph

Jul 31st, 2018
284
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <ATX2.h>
  2. int x,y,i;
  3. void setup(){
  4.   glcdMode(1);
  5.   setTextSize(3);
  6. }
  7. void loop(){
  8.    x=0;
  9.    for (i=0;i<20;i++){x=analog(0)+x;}
  10.    x=x/20;
  11.    y = map(x,0,1023,0,160);
  12.    glcd(1,0,"%d  ",y);
  13.    glcdFillRect(0,80,y,10,GLCD_RED);
  14.    glcdFillRect(y,80,160-y,10,GLCD_BLACK);
  15. }
Advertisement
Add Comment
Please, Sign In to add comment