*** Notes on how the code should work to control trains *** Must know name/pin of each bluetooth device to pair with. Each train route should be mapped out - calculate average time needed to complete each section of route - look for overlaps in routes at similar times - include +/- time needed to complete each section - adjust for slowdowns due to trains in adjacent sections ADC: - read track voltage - measure pressure on coupler (sense when car is bumped in to, or when cars decouple) DAC: - for sound output I/O: - forward light - reverse light - cab light - smoke - (O) wheel rotation ----- Bluetooth commands ----- INPUTS: Svvv Speed (0-255) Rvvv Rate of speed change (0-255) Ds Direction (0=forward, 1=reverse) An Play an audio sound Inns Set I/O n (0-99) to state s (0/1) LtnnAn Link an event type (A/D) number (0-99) to an audio (0-9) Example: link chuff-chuff sound to the speed of wheels OUTPUTS: Otnnvvv Output value of sensor type (A/D), number nn (0-99), value (0-255) AT Check the connection AT+VERSION AT+NAMExyz *Change name AT+PINxxxx *change pin, xxxx is the pin number AT+BAUDx *change baud rate, x is baud rate code 1=1200 2=2400 3=4800 4=9600 5=19200 6=38400 7=57600 8=115200 9=230400 A=460800 B=921600 C=1382400 *No space between command and code ----- IDEAS TO IMPLEMENT ----- * Flash cab light to show status - Comes on solid when first turned on - Flashes while trying to establish a connection - turns off once the code enters the main loop * Each loco provides its own webserver - Only send out basic output - point to raspi for shared CSS formatting