Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Olimex Pinguino Led/Button IO Test
09-12-2015, 12:14 PM, (This post was last modified: 09-12-2015, 08:57 PM by jwzumwalt.)
#1
Olimex Pinguino Led/Button IO Test
Here is a test...

Code:
/*
Test Led & Button IO
Purpose: LED's wig wag and serial port show LED & button IO values
'
Olimex Pinguino 32bit Micro board
-------------------------------------
int GREENLED   = pin 32, IDE 32;    // USERLED/LED1
int YELLOWLED  = pin 10, IDE 10;    // LED2
int BUTTON     = pin 41, IDE 41;    // USERBUTTON up=1, dn=0

*/

 int CNT = 0;
 
 void setup() {
   pinMode(USERBUTTON, INPUT);     // pin 41, IDE 41, USERBUTTON
   pinMode(GREENLED, OUTPUT);      // pin 13, IDE 13, USERLED/GREENLED/LED1  
   pinMode(YELLOWLED, OUTPUT);     // pin 10; IDE 10, YELLOWLED/LED2          
 }  // end setup
 
 void loop() {
 
   CNT++;
   
     // show text with ansi control
     CDC.printf("count = %d\r\n\r\n",CNT);
     
     CDC.printf("USERBUTTON = %d\r\n\r\n",USERBUTTON);  // show button pin value
     
     CDC.printf("GREENLED   = %d\r\n",GREENLED);        // show green led pin value
     CDC.printf("USERLED    = %d\r\n",USERLED);
     CDC.printf("LED1       = %d\r\n\r\n",LED1);
     
     CDC.printf("YELLOWLED  = %d\r\n",YELLOWLED);       // show yellow led pin value
     CDC.printf("LED2       = %d\r\n",LED2);
     CDC.print("\033[0m\033[ H");       // ansi control, clear & cursor to home
   
      // using system constants
   if (CNT%2 == 0) {              // even number
     digitalWrite(GREENLED, 1);   // green led
     digitalWrite(YELLOWLED, 0);  // yellow led
   } else {                       // odd number
     digitalWrite(GREENLED, 0);   // green led
     digitalWrite(YELLOWLED, 1);  // yellow led
   }
   delay(50);  // fast wig/wag
   
      // using pin numbers
   if (CNT%2 == 0) {              // even number
     digitalWrite(13, 1);         // green led
     digitalWrite(10, 0);         // yellow led
   } else {                       // odd number
     digitalWrite(13, 0);         // green led
     digitalWrite(10, 1);         // yellow led
   }
   delay(50);  // fast wig/wad  

 }  // end loop
----------------
Thanks,
j
wzumwalt
 (\__/)
 (='.'=)
 (")_(")
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)