// Displays the battery voltage. void bat_test() { int bat = read_battery_millivolts_x2(); print_long(bat); print("mV"); delay_ms(100); }
int main() { play_from_program_space(PSTR(">g32>>c32")); // Play welcoming notes. while(1) { // Print battery voltage (in mV) on the LCD. clear(); print_long(read_battery_millivolts_x2()); red_led(1); // Turn on the red LED. delay_ms(200); // Wait for 200 ms. red_led(0); // Turn off the red LED. delay_ms(200); // Wait for 200 ms. } }
void test() { unsigned char button; clear(); delay(200); print("Orangutan"); // print to the top line of the LCD delay_ms(400); // delay 200 ms lcd_goto_xy(0, 1); // go to the start of the second LCD line print(" X2"); // print to the bottom line of the LCD red_led(1); delay_ms(100); green_led(1); delay_ms(100); red_led2(1); delay_ms(100); green_led2(1); delay_ms(100); yellow_led(1); delay_ms(100); red_led(0); delay_ms(100); green_led(0); delay_ms(100); red_led2(0); delay_ms(100); green_led2(0); delay_ms(100); yellow_led(0); delay_ms(100); clear(); // clear the LCD, move cursor to start of top line print(" VBAT"); do { // Perform 10-bit analog-to-digital conversions on ADC channel 6. // Average ten readings and return the result, which will be one // third of the battery voltage when the "ADC6 = VBAT/3" solder // bridge is in place on the bottom of the Orangutan PCB int vbat = read_battery_millivolts_x2(); lcd_goto_xy(0, 1); // go to the start of the second LCD line print_long(vbat); // display battery voltage in millivolts print(" mV "); // display the units delay_ms(50); // delay for 50 ms button = button_is_pressed(ANY_BUTTON); // check for button press } while (button == 0); // loop if no buttons are being pressed red_led(1); green_led(1); red_led2(1); green_led2(1); yellow_led(1); // *** MAIN LOOP *** while (1) // loop forever { if (button & TOP_BUTTON) // if the top button is pressed button = melodyTest(); // this func. loops until next button press else if (button & MIDDLE_BUTTON) // if the middle button is pressed button = IOTest(); // this func. loops until next button press else if (button & BOTTOM_BUTTON) // if the bottom button is pressed button = motorTest(); // this func. loops until next button press } }