#include #include #define TESTPIN 10 JEMLCD1 lcd(8); byte cnt =0; byte val= 0; unsigned int analog_val; // this a really rough sample sketch. We'll write something fancier later. Have fun but use at your own risk. void setup() { lcd.init(); lcd.setBitRate(57600); lcd.pinMode(TESTPIN, OUTPUT); lcd.pinMode(0, INPUT); lcd.digitalWrite(0, 1); // turn on pullup } void loop() { // delay(50); // Segment API: // setSegment(digit, segments) // // digit: which digit to set the segmetns on. (0..5) // segments: Bit-field of segemnts to set. 1= on, 0=off; bits are: EDC-FGBA // //lcd.setSegment(1, 0xEF); // set all segments on digit #1 //lcd.setSegments(5, cnt); // Digit API: // setDigit(digit, value) // // digit: which digit to set the value of. (0..5) // value: value the digit should display: 0..9, ' ', '-', '0'..'9', // 'A', 'B', 'C', 'D', 'E', 'F', 'H', 'L', 'N', 'O', 'P', 'U', 'u' // lcd.setDigit(5, '5'); // lcd.setDigit(4, '4'); // lcd.setDigit(2, '2'); // lcd.setDigit(1, '1'); // lcd.setDigit(0, '0'); // Icon API: // setIcons(set, clear) // // set: Bit-field fo icons to set // clear: Bit-field of icons to clear // Use the pre-defined icon names to build the bit-fields: // START_ICON, STOP_ICON, CLEAR_ICON, LOBAT_ICON, COLON_ICON, DP_ICON, CFM_ICON, PSI_ICON, BAR_ICON, FBA_ICON // //lcd.setIcons(START_ICON | COLON_ICON, 0); // Turn on START and COLON icons, turn off no icons //lcd.setIcons(0, START_ICON); // Turn on no icons, turn off the START icon, leaving the COLON on. // Display values API: // display(value, field= 0, format= 0); // // value: the value to display // field: where on the display to display the value // format: how to display the value. // // field | format | value range | // 0 | 0 | -99.. 1999 | displays on the right set of digits // 0 | 1 | 0..1999 | displays on the right set of digits; 5 => 005, 42 => 042 // 1 | 0 | -9..99 | displays on the left set of digits // 1 | 1 | 0.99 | displays on the left set of digits; 5 => 05 //lcd.display(cnt%100, 1); // cnt++; // RGB LED API: // setREGB(red, green, blue) // // red the brightness of the red LED, 0 off 255 full on // green the brightness of the green LED, 0 off 255 full on // blue the brightness of the blue LED, 0 off 255 full on // //lcd.setRGB(random(64), random(64), random(64)); // Speaker API: // beep(freq, duration) // // Higher frequency number are lower pitch. Duration is in incrementis of 8mS. //lcd.beep(random(0,255), 5); // Buttrons API // byte buttons() // // return value bitmask is a '1' when a button press event is detected. A reference may // also be passed into buttons to read the current state: buttons(&btnState). // lcd.JEMdigitalWrite (TESTPIN,1); // delay(500); // lcd.JEMdigitalWrite (TESTPIN,0); // delay(250); // analog_val = lcd.JEManalogRead(6); // lcd.display(analog_val); /* echo data back on the RS-232 bus if (lcd.available()){ val = lcd.read(); lcd.write(val); } // */ val= lcd.buttons(); // Serial.print(val, DEC); switch(val) { case 0x01: lcd.setRGB(random(64), random(64), random(64)); lcd.setIcons(0xffff, 0); lcd.setContrast(0x00); break; case 0x80: lcd.display(cnt%100, 1); lcd.beep (3, 25); if (cnt++ == 15) cnt = 0; lcd.display (cnt,1,1); lcd.setContrast(0x3F); break; } }