Advertisement
KRITSADA

IPST-SE Read ADC from Analog 0 and Show Bargraph

Sep 12th, 2017
265
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.88 KB | None | 0 0
  1. /*****************************************************
  2.  *   TITLE : Read ADC from Analog 0 and Show Bargraph
  3.  *   CATAGORIES : IPST/GLCD
  4.  *   CREATED DATE : SEPTEMBER 13, 2017
  5.  *   AUTHOR : KRITSADA JAIYEN
  6.  *   WEBSITE : HTTP://WWW.INEX.CO.TH
  7.  *   MCU : IPST-SE
  8.  *   Thai DESCRIPTION : อ่านค่าจากช่องอะนาลอกช่อง 0
  9.  *   ในช่วง 0-160 นำค่าแสดงผลที่หน้าจอแนวนอน
  10.  *   นำผลที่ได้แสดงเป็นกราฟแท่งด้วย
  11.  ******************************************************/
  12. #include <ipst.h> // include file for IPST-SE
  13. int x;
  14. void setup(){
  15.   glcdMode(1);
  16.   setTextSize(3);
  17. }
  18. void loop(){
  19.    x = map(analog(0),0,1023,0,160);
  20.    glcd(1,0,"%d  ",x);
  21.    glcdFillRect(0,80,x,10,GLCD_RED);
  22.    glcdFillRect(x,80,160-x,10,GLCD_BLACK);
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement