# Car alarm # The finch sounds an alarm, alternating high pitch sounds and # flashing red abd blue lights, until its nose is turned up from time import sleep from lib.finch import Finch finch = Finch() x = 0 while x > -0.5: x, y, z, tap, shake = finch.acceleration() finch.led("#FF0000") # set the led to red finch.buzzer(1.0, 250) sleep(1.05) finch.led("#0000FF") # set the led to blue finch.buzzer(1.0, 400) sleep(1.05) finch.halt() finch.close()
window.addstr(0, 0, "Hit 'q' to quit") window.move(2, 0) window.refresh() key = '' while key != ord('q'): key = window.getch() window.addch(2, 0, key) window.refresh() if key == curses.KEY_UP: window.clrtobot() window.addstr(2, 0, "Finch goes forward!") myFinch.wheels(1, 1) sleep(0.1) myFinch.halt() elif key == curses.KEY_DOWN: window.clrtobot() window.addstr(2, 0, "Finch goes backwards!") myFinch.wheels(-1, -1) sleep(0.1) myFinch.halt() elif key == curses.KEY_LEFT: window.clrtobot() window.addstr(2, 0, "Finch goes left!") myFinch.wheels(0, 1) sleep(0.1) myFinch.halt()