h&n      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdef g h i j k l m n o p q r s t u v w x y z { | } ~(c) Levent ErkokBSD3erkokl@gmail.com experimental Safe-Inferred<hArduinoConvert a character to a bit-pattern, suitable for display on a seven-segment display. Note that most characters are just not representable in a 7-segment display, in which case we map it to . However, some substitutions are done, for instance '(' is displayed the same as '['.The return value is a , although only 7-bits are used; the least significant bit will always be 0. With the traditional coding, the bits correspond to segments ABCDEFG0, i.e., most-significant-bit will be for segment A, next for segment B, and so on.(c) Levent ErkokBSD3erkokl@gmail.com experimental Safe-Inferred hArduino2Delay (wait) for the given number of milli-secondshArduinoA simple printer that can keep track of sequence numbers. Used for debugging purposes.hArduino Show a byte in a visible format.hArduinoShow a list of byteshArduinoShow a number as a binary valuehArduinoTurn a lo/hi encoded Arduino string constant into a Haskell stringhArduinoTurn a lo/hi encoded Arduino sequence into a bunch of words, again weird encoding.hArduinoTurn a normal byte into a lo/hi Arduino byte. If you think this encoding is just plain weird, you're not alone. (I suspect it has something to do with error-correcting low-level serial communication of the past.)hArduinoConvert a word to it's bytes, as would be required by Arduino commshArduino!Inverse conversion for word2Bytes (c) Levent ErkokBSD3erkokl@gmail.com experimental Safe-Inferred',hArduinoSys-ex commands, see: 5http://firmata.org/wiki/Protocol#Sysex_Message_FormathArduino0x00 2nd SysEx data byte is a chip-specific command (AVR, PIC, TI, etc).hArduino0x69* ask for mapping of analog to pin numbershArduino0x6A reply with mapping infohArduino0x6B4 ask for supported modes and resolution of all pinshArduino0x6C+ reply with supported modes and resolutionhArduino0x6D( ask for a pin's current mode and valuehArduino0x6E+ reply with a pin's current mode and valuehArduino0x6F+ analog write (PWM, Servo, etc) to any pinhArduino0x70) set max angle, minPulse, maxPulse, freqhArduino0x71( a string message with 14-bits per charhArduino0x74 Pulse, see: /https://github.com/rwldrn/johnny-five/issues/18hArduino0x75( shiftOut config/data message (34 bits)hArduino0x762 I2C request messages from a host to an I/O boardhArduino0x770 I2C reply messages from an I/O board to a hosthArduino0x78 Configure special I2C settings such as power pins and delay timeshArduino0x79) report name and version of the firmwarehArduino0x7A sampling intervalhArduino0x7E) MIDI Reserved for non-realtime messageshArduino0x7F% MIDI Reserved for realtime messageshArduinoFirmata commands, see: .http://firmata.org/wiki/Protocol#Message_TypeshArduino0xE0 pinhArduino0x90 porthArduino0xC0 pinhArduino0xD0 porthArduino 0xF0hArduino 0xF4hArduino 0xF7hArduino 0xF9hArduino 0xFFhArduinoThe Arduino monad.hArduinoState of the computationhArduinoCurrent debugging routinehArduino6Clean-up and quit with a hopefully informative messagehArduino#Serial port we are communicating onhArduino7The ID of the board (as identified by the Board itself)hArduinoCurrent state of the boardhArduino Incoming messages from the boardhArduinoCapabilities of the boardhArduinoThreadId of the listenerhArduinoState of the boardhArduinoCapabilities of the boardhArduinoWhich analog pins are reportinghArduino Which digital pins are reportinghArduinoFor-each pin, store its datahArduino:Semaphore list to wake-up upon receiving a digital messagehArduinoLCD's attached to the boardhArduino3State of the LCD, a mere 8-bit word for the HitachihArduinoDisplay mode (leftrightscrolling etc.)hArduinoDisplay control (blink onoff, display on off etc.)hArduino4Count of custom created glyphs (typically at most 8)hArduinoActual controllerhArduinoHitachi LCD controller: See:  ;http://en.wikipedia.org/wiki/Hitachi_HD44780_LCD_controller. We model only the 4-bit variant, with RS and EN lines only. (The most common Arduino usage.) The data sheet can be seen at:  4http://lcd-linux.sourceforge.net/pdfdocs/hd44780.pdf.hArduino Hitachi pin  4: Register-selecthArduino Hitachi pin  6: EnablehArduino Hitachi pin 11 : Data line 4hArduino Hitachi pin 12 : Data line 5hArduino Hitachi pin 13 : Data line 6 hArduino Hitachi pin 14 : Data line 7 hArduino)Number of rows (typically 1 or 2, upto 4) hArduino,Number of cols (typically 16 or 20, upto 40) hArduino!Set to True if 5x10 dots are used hArduinoLCD's connected to the boardhArduinoData associated with a pinhArduino1What the board is capable of and current settingshArduinoCapabilities of a pinhArduinoAnalog pin number, if anyhArduinoAllowed modes and resolutionshArduinoResolution, as referred to in  1http://firmata.org/wiki/Protocol#Capability_Query TODO: Not quite sure how this is used, so merely keep it as a Word8 nowhArduino(A response, as returned from the ArduinohArduino)Firmware version (maj/min and indentifierhArduinoCapabilities reporthArduinoAnalog pin mappingshArduinoStatus of a porthArduinoStatus of an analog pinhArduinoRepsonse to a PulseInCommandhArduino)Represents messages currently unsupportedhArduinoA request, as sent to ArduinohArduinoSend system resethArduino#Query the Firmata version installedhArduino#Query the capabilities of the boardhArduino Query the mapping of analog pinshArduinoSet the mode on a pinhArduino,Digital report values on port enable/disablehArduino*Analog report values on pin enable/disablehArduino"Set the values on a port digitallyhArduino,Send an analog-write; used for servo controlhArduinoSet the sampling intervalhArduino>Request for a pulse reading on a pin, value, duration, timeouthArduinoThe mode for a pin.hArduino Digital inputhArduinoDigital outputhArduino Analog inputhArduino$PWM (Pulse-Width-Modulation) output hArduinoServo Motor controllerhArduinoShift controllerhArduino)I2C (Inter-Integrated-Circuit) connectionhArduinoNB. No explicit supporthArduinoNB. No explicit supporthArduinoNB. No explicit supporthArduinoNB. No explicit supporthArduinoNB. No explicit supporthArduino&A mode we do not understand or supporthArduinoA pin on the Arduino, as viewed by the library; i.e., real-pin numbershArduino3A pin on the Arduino, as specified by the user via , , and  functions.hArduinoA port (containing 8 pins)hArduinoThe port numberhArduino seconds, which is plenty infrequent for all practical needs.).hArduinoPin to send the pulse onhArduino Pulse valuehArduinoTime, in microseconds, to signal beginning of pulse; will send the opposite value for this amounthArduino(Pulse duration, measured in microseconds!"#$%&'()*+,-./012(c) Levent ErkokBSD3erkokl@gmail.com experimental Safe-Inferred'c+3hArduino0An abstract symbol type for user created symbolshArduino*Various control masks for the Hitachi44780hArduinobit 0 Controls whether cursor blinkshArduinobit 1 Controls whether cursor is onhArduinobit 2 Controls whether display is onhArduinobit 0 Controls left/right scrollhArduinobit 1 Controls left/right entry modehArduinoCommands understood by HitachihArduino Convert a command to a data-wordhArduino+Initialize the LCD. Follows the data sheet  4http://lcd-linux.sourceforge.net/pdfdocs/hd44780.pdf, page 46; figure 24.hArduino*Get the controller associated with the LCDhArduino$Send a command to the LCD controllerhArduino%Send 4-bit data to the LCD controllerhArduinoBy controlling the enable-pin, indicate to the controller that the data is ready for it to process.hArduinoTransmit data down to the LCDhArduinoHelper function to simplify library programming, not exposed to the user.4hArduinoRegister an LCD controller. When registration is complete, the LCD will be initialized so that:Set display ON (Use @ / ? to change.)Set cursor OFF (Use > / = to change.)Set blink OFF (Use < / ; to change.)Clear display (Use 6 to clear, 5 to display text.)"Set entry mode left to write (Use A / B to control.)Set autoscrolling OFF (Use D / C to control.)'Put the cursor into home position (Use 8 or 7 to move around.)5hArduino8Write a string on the LCD at the current cursor position6hArduino Clear the LCD7hArduino Send the cursor to home position8hArduinoSet the cursor location. The pair of arguments is the new column and row numbers respectively:The first value is the column, the second is the row. (This is counter-intuitive, but is in line with what the standard Arduino programmers do, so we follow the same convention.)1Counting starts at 0 (both for column and row no)If the new location is out-of-bounds of your LCD, we will put it the cursor to the closest possible location on the LCD.9hArduinoScroll the display to the left by 1 character. Project idea: Using a tilt sensor, scroll the contents of the display left/right depending on the tilt. :hArduino.Scroll the display to the right by 1 characterhArduinoDisplay characteristics helper, set the new control/mode and send appropriate commands if anything changedhArduinoUpdate the display control wordhArduinoUpdate the display mode wordhArduino$Convert the mask value to the bit nohArduinoClear by the maskhArduinoSet by the mask;hArduinoDo not blink the cursor<hArduinoBlink the cursor=hArduinoHide the cursor. Note that a blinking cursor cannot be hidden, you must first turn off blinking.>hArduinoShow the cursor?hArduinoTurn the display off. Note that turning the display off does not mean you are powering it down. It simply means that the characters will not be shown until you turn it back on using @. (Also, the contents will not be forgotten when you call this function.) Therefore, this function is useful for temporarily hiding the display contents.@hArduinoTurn the display onAhArduino$Set writing direction: Left to RightBhArduino$Set writing direction: Right to LeftChArduinoTurn on auto-scrolling. In the context of the Hitachi44780 controller, this means that each time a letter is added, all the text is moved one space to the left. This can be confusing at first: It does not mean that your strings will continuously scroll: It just means that if you write a string whose length exceeds the column-count of your LCD, then you'll see the tail-end of it. (Of course, this will create a scrolling effect as the string is being printed character by character.)Having said that, it is easy to program a scrolling string program: Simply write your string by calling 5, and then use the 9 and :> functions with appropriate delays to simulate the scrolling.DhArduino.Turn off auto-scrolling. See the comments for C for details. When turned off (which is the default), you will not see the characters at the end of your strings that do not fit into the display.EhArduino Flash contents of the LCD screenFhArduinoCreate a custom symbol for later display. Note that controllers have limited capability for such symbols, typically storing no more than 8. The behavior is undefined if you create more symbols than your LCD can handle.The input is a simple description of the glyph, as a list of precisely 8 strings, each of which must have 5 characters. Any space character is interpreted as a empty pixel, any non-space is a full pixel, corresponding to the pixel in the 5x8 characters we have on the LCD. For instance, here's a happy-face glyph you can use:  [ " " , "@ @" , " " , " " , "@ @" , " @@@ " , " " , " " ] GhArduino/Display a user created symbol on the LCD. (See F for details.)HhArduinoAccess an internally stored symbol, one that is not available via its ASCII equivalent. See the Hitachi datasheet for possible values:  4http://lcd-linux.sourceforge.net/pdfdocs/hd44780.pdf, Table 4 on page 17./For instance, to access the symbol right-arrow:Locate it in the above table: Right-arrow is at the second-to-last row, 7th character from left.Check the upper/higher bits as specified in the table: For Right-arrow, upper bits are 0111 and the lower bits are 1110; which gives us the code 01111110, or 0x7E./So, right-arrow can be accessed by symbol code H 0x7E, which will give us a 3$ value that can be passed to the G* function. The code would look like this: +lcdWriteSymbol lcd (lcdInternalSymbol 0x7E).EhArduino Flash counthArduinoDelay amount (in milli-seconds)" 3456789:;<=>?@ABCDEFGH"  46578CD9:AB<;>=@?3HGFE(c) Levent ErkokBSD3erkokl@gmail.com experimental Safe-Inferredc& !"#$%&'()*+,-./012& %01&()*+,-/.2'"#$!(c) Levent ErkokBSD3erkokl@gmail.com experimental Safe-InferredgIhArduinoComputes the amount of time a push-button is connected to input pin 2 on the Arduino. We will wait for at most 5 seconds, as a further demonstration of the time-out facility. Note that the timing is done on the host side, so this measurement is inherently inaccurate.The wiring is straightforward: Simply put a push-button between digital input 2 and +5V, guarded by a 10K resistor: http://github.com/LeventErkok/hArduino/raw/master/System/Hardware/Arduino/SamplePrograms/Schematics/PulseIn.pngJhArduinoSend pulses on a led as requested by the user. Note that the timing is computed on the host side, thus the duration of the pulse is subject to some error due to the Firmata communication overhead.Wiring: Simply a led on pin 13: http://github.com/LeventErkok/hArduino/raw/master/System/Hardware/Arduino/SamplePrograms/Schematics/Blink.pngIJIJ(c) Levent ErkokBSD3erkokl@gmail.com experimental Safe-InferredkKhArduino%There are 5 keys on the OSepp shield.QhArduinoThe OSepp LCD Shield is a 16x2 LCD using a Hitachi Controller Furthermore, it has backlight, and 5 buttons. The hook-up is quite straightforward, using our existing Hitachi44780 controller as an example. More information on this shield can be found at: http://osepp.com/products/shield-arduino-compatible/16x2-lcd-display-keypad-shield/RhArduinoInitialize the shield. This is essentially simply registering the lcd with the HArduino library. In addition, we return two values to the user:$A function to control the back-light'A function to read (if any) key-pressedShArduinoNumber guessing game, as a simple LCD demo. User thinks of a number between 0 and 1000, and the Arduino guesses it.ThArduinoEntry to the classing number guessing game. Simply initialize the shield and call our game function. KPONMLQRST QKPONMLRST#(c) Antoine R. Dumont, Levent ErkokBSD3erkokl@gmail.com experimental Safe-InferredpFUhArduino,A dit or a dah is all we need for Morse: A dit is a dot; and a dah) is a dash in the Morsian world. We use X and Y to indicate a letter and a word break so we can insert some delay between letters and words as we transmit.ZhArduinoMorse code dictionary[hArduinoGiven a sentence, decode it. We simply drop any letters that we do not have a mapping for.\hArduino7Given a morsified sentence, compute the delay times. A + value means turn the led on that long, a # value means turn it off that long.]hArduinoFinally, turn a full sentence into a sequence of blink on/off codes^hArduinoA simple demo driver. To run this example, you only need the Arduino connected to your computer, no other hardware is needed. We use the internal led on pin 13. Of course, you can attach a led to pin 13 as well, for artistic effect. http://github.com/LeventErkok/hArduino/raw/master/System/Hardware/Arduino/SamplePrograms/Schematics/Blink.png UYXWVZ[\]^ UYXWVZ[\]^(c) Levent ErkokBSD3erkokl@gmail.com experimental Safe-InferreduA`hArduino1Connections for a basic hitachi controller. See  ;http://en.wikipedia.org/wiki/Hitachi_HD44780_LCD_controller for pin layout. For this demo, simply connect the LCD pins to the Arduino as follows: LCD pin 01 to GNDLCD pin 02 to +5VLCD pin 03 to a 10K potentiometer's viperLCD pin 04 to Arduino pin 12LCD pin 05 to GNDLCD pin 06 to Arduino pin 11LCD pin 11 to Arduino pin 5LCD pin 12 to Arduino pin 4LCD pin 13 to Arduino pin 3LCD pin 14 to Arduino pin 2![If backlight is needed] LCD pin 15 to +5V![If backlight is needed] LCD pin 16 to GND via 220ohm resistor http://github.com/LeventErkok/hArduino/raw/master/System/Hardware/Arduino/SamplePrograms/Schematics/LCD.pngahArduinoThe happy glyph. See F' for details on how to create new ones.bhArduinoThe sad glyph. See F' for details on how to create new ones.chArduinoAccess the LCD connected to Arduino, making it show messages we read from the user and demonstrate other LCD control features offered by hArduino.`abc`abc(c) Levent ErkokBSD3erkokl@gmail.com experimental Safe-InferredyTdhArduino'Sound travels 343.2 meters per second ( +http://en.wikipedia.org/wiki/Speed_of_sound). The echo time is round-trip, from the sensor to the object and back. Thus, if echo is high for d3 microseconds, then the distance in centimeters is: ; d * 10^-6 * 343.2 * 10^2 / 2 = 1.716e-2 * d ehArduinoMeasure and display the distance continuously, as reported by an HC-SR04 sensor.Wiring: Simply connect VCC and GND of HC-SR04 to Arduino as usual. The Echo8 line on the sensor is connected to Arduino pin 2. The Trig' line is connected on the board to the Echo line, i.e., they both connect to the same pin on the Arduino. We also have a led on pin 13 that we will light-up if the distance detected is less than 5 centimeters, indicating an impending crash! http://github.com/LeventErkok/hArduino/raw/master/System/Hardware/Arduino/SamplePrograms/Schematics/Distance.pngdede (c) Levent ErkokBSD3erkokl@gmail.com experimental Safe-Inferred{fhArduinoTwo push-button switches, controlling a counter value. We will increment the counter if the first one (bUp:) is pressed, and decrement the value if the second one (bDown) is pressed. We also have a led connected to pin 13 (either use the internal or connect an external one), that we light up when the counter value is 0.Wiring is very simple: Up-button connected to pin 4, Down-button connected to pin 2, and a led on pin 13. http://github.com/LeventErkok/hArduino/raw/master/System/Hardware/Arduino/SamplePrograms/Schematics/Counter.pngff (c) Levent ErkokBSD3erkokl@gmail.com experimental Safe-Inferred~4ghArduinoRead the value of a push-button (NO - normally open) connected to input pin 2 on the Arduino. We will continuously monitor and print the value as it changes. Also, we'll turn the led on pin 13 on when the switch is pressed.The wiring is straightforward: Simply put a push-button between digital input 2 and +5V, guarded by a 10K resistor: http://github.com/LeventErkok/hArduino/raw/master/System/Hardware/Arduino/SamplePrograms/Schematics/Button.pnggg (c) Levent ErkokBSD3erkokl@gmail.com experimental Safe-InferredihhArduino?@ABCDEFGHjqponmklr{zxwuvty|s !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~                        ;&v #hArduino-1.2-I0P1eGxlPHKKtrVXBaZ4PH/System.Hardware.Arduino.Parts.SevenSegmentCodesSystem.Hardware.Arduino!System.Hardware.Arduino.Parts.LCD,System.Hardware.Arduino.SamplePrograms.Pulse/System.Hardware.Arduino.SamplePrograms.NumGuess,System.Hardware.Arduino.SamplePrograms.Morse*System.Hardware.Arduino.SamplePrograms.LCD/System.Hardware.Arduino.SamplePrograms.Distance.System.Hardware.Arduino.SamplePrograms.Counter-System.Hardware.Arduino.SamplePrograms.Button,System.Hardware.Arduino.SamplePrograms.Blink-System.Hardware.Arduino.SamplePrograms.Analog,System.Hardware.Arduino.Parts.ShiftRegisters3System.Hardware.Arduino.SamplePrograms.SevenSegment#System.Hardware.Arduino.Parts.Servo,System.Hardware.Arduino.SamplePrograms.Servo#System.Hardware.Arduino.Parts.Piezo2System.Hardware.Arduino.SamplePrograms.JingleBellsSystem.Hardware.Arduino.UtilsSystem.Hardware.Arduino.Data System.Hardware.Arduino.ProtocolSystem.Hardware.Arduino.CommSystem.Hardware.Arduino.FirmataSystem.Hardware.Arduino.Partschar2SSArduino LCDController Hitachi44780lcdRSlcdENlcdD4lcdD5lcdD6lcdD7lcdRowslcdCols dotMode5x10LCDPinModeINPUTOUTPUTANALOGPWMSERVOSHIFTI2CONEWIRESTEPPERENCODERSERIALPULLUP UNSUPPORTEDPinpindigitalanalog withArduino queryFirmwaredelaytimetimeOut setPinMode digitalWritepullUpResistor digitalReadwaitForwaitAny waitAnyHigh waitAnyLowpulsepulseOut_hostTimingpulseIn_hostTiming analogRead analogWritesetAnalogSamplingInterval LCDSymbol lcdRegisterlcdWritelcdClearlcdHome lcdSetCursorlcdScrollDisplayLeftlcdScrollDisplayRight lcdBlinkOff lcdBlinkOn lcdCursorOff lcdCursorOn lcdDisplayOff lcdDisplayOnlcdLeftToRightlcdRightToLeftlcdAutoScrollOnlcdAutoScrollOfflcdFlashlcdCreateSymbollcdWriteSymbollcdInternalSymbol pulseInDemo pulseOutDemoKeyKeyRightKeyLeftKeyUpKeyDown KeySelectosepp initOSeppnumGuess guessGameMorseDitDahLBreakWBreakdictdecodemorsifytransmit morseDemo $fShowMorsehitachihappysadlcdDemomicroSecondsToCentimetersdistancecounterbuttonblink analogVal SR_74HC595serialnEnablerClocksClocknClearmbBits ShiftRegistersizename dataSheet initializedisableenableclearpushstoreread$fShiftRegisterSR_74HC595sr sevenSegmentServoattachsetAngleservo servoAnalogDurationWholeHalfQuarterEightNoteABCDEFGRPiezospeakersilenceplayNote playNotesrest $fEqDuration$fShowDuration$fEqNote $fShowNote jingleBellsmainbase GHC.MaybeNothingGHC.WordWord8mkDebugPrintershowByte showByteListshowBin getStringfromArduinoBytestoArduinoBytes word2Bytes bytes2WordsSysExCmdRESERVED_COMMANDANALOG_MAPPING_QUERYANALOG_MAPPING_RESPONSECAPABILITY_QUERYCAPABILITY_RESPONSEPIN_STATE_QUERYPIN_STATE_RESPONSEEXTENDED_ANALOG SERVO_CONFIG STRING_DATAPULSE SHIFT_DATA I2C_REQUEST I2C_REPLY I2C_CONFIGREPORT_FIRMWARESAMPLING_INTERVALSYSEX_NON_REALTIMESYSEX_REALTIME FirmataCmdANALOG_MESSAGEDIGITAL_MESSAGEREPORT_ANALOG_PINREPORT_DIGITAL_PORT START_SYSEX SET_PIN_MODE END_SYSEXPROTOCOL_VERSION SYSTEM_RESET ArduinoStatemessagebailOutport firmataID boardState deviceChannel capabilities listenerTid BoardStateboardCapabilitiesanalogReportingPinsdigitalReportingPins pinStatesdigitalWakeUpQueuelcdsLCDDatalcdDisplayModelcdDisplayControl lcdGlyphCount lcdControllerPinDataBoardCapabilitiesPinCapabilitiesanalogPinNumber allowedModes ResolutionResponseFirmware Capabilities AnalogMappingDigitalMessage AnalogMessage PulseResponse UnimplementedRequest SystemReset QueryFirmwareCapabilityQueryAnalogMappingQuery SetPinMode DigitalReport AnalogReportDigitalPortWriteAnalogPinWriteSamplingIntervalPulseIPinPortportNopinPort pinPortIndexdebugdie getPinModes getPinDatacomputePortData digitalWakeUp firmataCmdVal getFirmataCmd sysExCmdValgetSysExCommandregisterPinModegetRemovalActionsgetModeActionsgetInternalPinconvertAndCheckPin $fShowPort $fShowPin $fShowIPin$fShowBoardCapabilities$fShowResponsepinValuepinModepinNo InternalPin userPinNoMixedPin AnalogPin DigitalPinsysExnonSysExpackageunpackageSysExunpackageNonSysExghc-prim GHC.TypesFalsesendrecv recvTimeOut setupListenerTrue waitGenericIntHitachi44780Mask LCD_BLINKON LCD_CURSORON LCD_DISPLAYONLCD_ENTRYSHIFTINCREMENT LCD_ENTRYLEFTCmd getCmdValinitLCD getControllersendCmdsendData pulseEnablewithLCDupdateDisplayDataupdateDisplayControlupdateDisplayModemaskBit clearMasksetMask Data.EitherLeftRight fallingEdgeservoPinminPulsemaxPulsepiezoPintempo frequencyintervalsetNote