KRITSADA

WirelessX RX Channel Programmer

Oct 21st, 2018
362
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.57 KB | None | 0 0
  1. #include <ATX2.h>
  2.  
  3. void setup()
  4. {
  5.   XIOinit();
  6.   glcdClear();
  7.   glcdMode(1);
  8.   setTextSize(2);
  9.   setTextColor(GLCD_ORANGE);
  10.   glcd(2,0,"Disconnect   ");
  11.   glcd(3,0,"Receiver     ");
  12.   glcd(4,0,"from (3) TxD1");
  13.   glcd(5,0,"and push (OK)");
  14. }
  15.  
  16. void loop()
  17. {
  18.   int RF_Channel;
  19.   while(1)
  20.   {
  21.     RF_Channel=knob(197);
  22.     if (RF_Channel<5)
  23.       RF_Channel=5;
  24.     if (RF_Channel>197)
  25.       RF_Channel=197;
  26.  
  27.     setTextSize(3);
  28.     setTextColor(GLCD_DOLLAR);
  29.     glcd(0,0,"RF:");
  30.     setTextColor(GLCD_YELLOW);
  31.     glcd(0,3,"%d  ",RF_Channel);
  32.     setTextSize(1);
  33.     setTextColor(GLCD_WHITE);
  34.     glcd(3,10,"^-- Turn KNOB");
  35.     delay(100);
  36.     setTextSize(2);
  37.     if (sw_OK())
  38.     {
  39.       pinMode(3,OUTPUT);
  40.       digitalWrite(3,LOW);
  41.       beep();
  42.       setTextColor(GLCD_GREEN);
  43.       glcd(2,0,"CONNECT...   ");
  44.       glcd(3,0,"Receiver to 3");
  45.       glcd(4,0,"and push (OK)");
  46.       glcd(5,0,"within 3 sec.");
  47.       while(!sw_OK());
  48.       digitalWrite(3,HIGH);
  49.       delay(200);
  50.       Serial1.begin(9600);
  51.       delay(2000);
  52.       Serial1.write('C');
  53.       Serial1.write('H');
  54.       Serial1.write(RF_Channel);
  55.       Serial1.flush();
  56.       setTextColor(GLCD_PINK);
  57.       glcd(2,0,"             ");
  58.       glcd(3,0,"             ");
  59.       glcd(4,0,"Programmed OK.");
  60.       glcd(5,0,"             ");
  61.       Serial1.end();
  62.       delay(1000);
  63.       setTextColor(GLCD_ORANGE);
  64.       glcd(2,0,"Disconnect   ");
  65.       glcd(3,0," Receiver    ");
  66.       glcd(4,0,"from TxD1 pin");
  67.       glcd(5,0,"and push (OK)");
  68.     }
  69.   }
  70. }
Advertisement
Add Comment
Please, Sign In to add comment