/* _JNJ` .JNMH` JMMF` `;. .NMM) `MN. MMM) (MML (MMM` MMML M I D N I G H T C o D E (NMMF MHNH NMML .MMM NMML .NMH 4MMNL .#F `4HNNL_ ` `"""` Copyright (C) 2004-2014 "Ian (Larry) Latter" Midnight Code is a registered trademark of Ian Latter. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, and mirrored at the Midnight Code web site; as at version 2 of the License only. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License (version 2) along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA, or see http://midnightcode.org/gplv2.txt */ int with_light = 1; int with_sound = 0; int start_delay = 4; int led = 13; int piezo = 11; void piezo_beep() { int frequency = 4000; for(int i = 0; i < ((frequency / 1000) * 400); i++) { digitalWrite(piezo, HIGH); delayMicroseconds(500000 / frequency); digitalWrite(piezo, LOW); delayMicroseconds(500000 / frequency); } } void user_notify(unsigned int count) { for(int i = 0; i < count; i++) { if(with_light) { digitalWrite(led, HIGH); } if(with_sound) { piezo_beep(); } if(with_light) { delay(250); digitalWrite(led, LOW); delay(250); } } } void setup() { pinMode(led, OUTPUT); Keyboard.begin(); delay(start_delay * 1000); user_notify(3); delay(750); Keyboard.print("IFS=\"\" ; "); Keyboard.print("LANG=C ; "); Keyboard.print("c=0 ; "); Keyboard.print("while read -s -u 3 -d '' -r -n 1 i ; "); Keyboard.print("do "); Keyboard.print(" printf -v b \"%i\" \"'$i\" ; "); Keyboard.print(" echo \" $((($c&128)>>7))$((($c&64)>>6))$((($c&32)>>5))$((($c&16)>>4))$((($c&8)>>3))$((($c&4)>>2))$((($c&2)>>1))$(($c&1)) "); Keyboard.print(" $((($b&128)>>7))$((($b&64)>>6))$((($b&32)>>5))$((($b&16)>>4))$((($b&8)>>3))$((($b&4)>>2))$((($b&2)>>1))$(($b&1))\" ; "); Keyboard.print(" ((c++)) ; "); Keyboard.print(" (($c==256)) && c=0 ; "); Keyboard.print(" sleep 0.005 ; "); Keyboard.println("done"); delay(500); user_notify(1); delay(1000); } void loop() { }