>%,      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstu v w x y z { | } ~  (c) Levent ErkokBSD3erkokl@gmail.com experimentalSafe 2Delay (wait) for the given number of milli-secondsVA simple printer that can keep track of sequence numbers. Used for debugging purposes. Show a byte in a visible format.Show a list of bytesShow a number as a binary valueBTurn a lo/hi encoded Arduino string constant into a Haskell stringSTurn a lo/hi encoded Arduino sequence into a bunch of words, again weird encoding.Turn 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.)CConvert a word to it's bytes, as would be required by Arduino comms!Inverse conversion for word2Bytes  (c) Levent ErkokBSD3erkokl@gmail.com experimentalSafeConvert 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 W. 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 experimentalNoneCINSys-ex commands, see: 5http://firmata.org/wiki/Protocol#Sysex_Message_Format0x00E 2nd SysEx data byte is a chip-specific command (AVR, PIC, TI, etc).0x69* ask for mapping of analog to pin numbers0x6A reply with mapping info0x6B4 ask for supported modes and resolution of all pins0x6C+ reply with supported modes and resolution0x6D( ask for a pin's current mode and value0x6E+ reply with a pin's current mode and value0x6F+ analog write (PWM, Servo, etc) to any pin0x70) set max angle, minPulse, maxPulse, freq0x71( a string message with 14-bits per char0x74 Pulse, see: /https://github.com/rwldrn/johnny-five/issues/180x75( shiftOut config/data message (34 bits)0x762 I2C request messages from a host to an I/O board0x770 I2C reply messages from an I/O board to a host0x78C Configure special I2C settings such as power pins and delay times0x79) report name and version of the firmware0x7A sampling interval0x7E) MIDI Reserved for non-realtime messages0x7F% MIDI Reserved for realtime messagesFirmata commands, see: .http://firmata.org/wiki/Protocol#Message_Types0xE0 pin0x90 port0xC0 pin0xD0 port 0xF0 0xF4 0xF7 0xF9 0xFFThe Arduino monad.State of the computationCurrent debugging routine6Clean-up and quit with a hopefully informative message#Serial port we are communicating on7The ID of the board (as identified by the Board itself)Current state of the board Incoming messages from the boardCapabilities of the boardThreadId of the listenerState of the boardCapabilities of the boardWhich analog pins are reporting Which digital pins are reportingFor-each pin, store its data:Semaphore list to wake-up upon receiving a digital messageLCD's attached to the board3State of the LCD, a mere 8-bit word for the HitachiDisplay mode (leftrightscrolling etc.)Display control (blink onoff, display on off etc.)4Count of custom created glyphs (typically at most 8)Actual controllerHitachi 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. Hitachi pin  4: Register-select Hitachi pin  6: Enable Hitachi pin 11 : Data line 4 Hitachi pin 12 : Data line 5 Hitachi pin 13 : Data line 6  Hitachi pin 14 : Data line 7 )Number of rows (typically 1 or 2, upto 4) ,Number of cols (typically 16 or 20, upto 40) !Set to True if 5x10 dots are used LCD's connected to the boardData associated with a pin1What the board is capable of and current settingsCapabilities of a pinAnalog pin number, if anyAllowed modes and resolutionsResolution, as referred to in  1http://firmata.org/wiki/Protocol#Capability_QueryI TODO: Not quite sure how this is used, so merely keep it as a Word8 now(A response, as returned from the Arduino)Firmware version (maj/min and indentifierCapabilities reportAnalog pin mappingsStatus of a portStatus of an analog pinRepsonse to a PulseInCommand)Represents messages currently unsupportedA request, as sent to ArduinoSend system reset#Query the Firmata version installed#Query the capabilities of the board Query the mapping of analog pinsSet the mode on a pin,Digital report values on port enable/disable*Analog report values on pin enable/disable"Set the values on a port digitally,Send an analog-write; used for servo controlSet the sampling interval>Request for a pulse reading on a pin, value, duration, timeoutThe mode for a pin. Digital inputDigital output Analog input$PWM (Pulse-Width-Modulation) output Servo Motor controllerShift controller)I2C (Inter-Integrated-Circuit) connectionNB. No explicit supportNB. No explicit supportNB. No explicit supportNB. No explicit supportNB. No explicit support&A mode we do not understand or supportFA pin on the Arduino, as viewed by the library; i.e., real-pin numbers3A pin on the Arduino, as specified by the user via , , and  functions.A port (containing 8 pins)The port number<Declare a pin by its index. For maximum portability, prefer  and  functions, which will adjust pin indexes properly based on which board the program is running on at run-time, as Arduino boards differ in their pin numbers. This function is provided for cases where a pin is used in mixed-mode, i.e., both for digital and analog purposes, as Arduino does not really distinguish pin usage. In these cases, the user has the proof obligation to make sure that the index used is supported on the board with appropriate capabilities.VDeclare an digital pin on the board. For instance, to refer to digital pin no 12 use  12.ZDeclare an analog pin on the board. For instance, to refer to analog pin no 0 simply use  0. Note that  0& on an Arduino UNO will be appropriately adjusted internally to refer to pin 14, since UNO has 13 digital pins, while on an Arduino MEGA, it will refer to internal pin 55, since MEGA has 54 digital pins; and similarly for other boards depending on their capabilities. (Also see the note on  for pin mappings.)qOn the Arduino, pins are grouped into banks of 8. Given a pin, this function determines which port it belongs to~On the Arduino, pins are grouped into banks of 8. Given a pin, this function determines which index it belongs to in its port1Debugging only: print the given string on stdout.5Bailing out: print the given string on stdout and die"Which modes does this pin support?Current state of the pinGiven a pin, collect the digital value corresponding to the port it belongs to, where the new value of the current pin is given The result is two bytes: First lsb: pins 0-6 on the port!Second msb: pins 7-13 on the portGIn particular, the result is suitable to be sent with a digital message,Keep track of listeners on a digital message&Compute the numeric value of a command#Convert a byte to a Firmata command Convert a  to a byteConvert a byte into a Keep track of pin-mode changeshA mode was removed from this pin, update internal state and determine any necessary actions to remove itbDepending on a mode-set call, determine what further actions should be executed, such as enabling disabling pinport reportingeOn the arduino, digital pin numbers are in 1-to-1 match with the board pins. However, ANALOG pins come at an offset, determined by the capabilities query. Users of the library refer to these pins simply by their natural numbers, which makes for portable programs between boards that have different number of digital pins. We adjust for this shift here.VSimilar to getInternalPin above, except also makes sure the pin is in a required mode.#Show instance for BoardCapabilitiesShow instance for ResponseShow instance for IPin Show instance for Pin Show instance for Port          +          (c) Levent ErkokBSD3erkokl@gmail.com experimentalNone-Wrap a sys-ex message to be sent to the boardConstruct a non sys-ex message]Package a request as a sequence of bytes to be sent to the board using the Firmata protocol.Unpackage a SysEx response Unpackage a Non-SysEx response!  ! (c) Levent ErkokBSD3erkokl@gmail.com experimentalNoneN -Run the Haskell program to control the board:aThe file path argument should point to the device file that is associated with the board. (COM1 on Windows, '/dev/cu.usbmodemFD131' on Mac, etc.)@The boolean argument controls verbosity. It should remain " unless you have communication issues. The print-out is typically less-than-useful, but it might point to the root cause of the problem.See &System.Hardware.Arduino.Examples.Blink for a simple example.#Send down a request.$3Receive a sys-ex response. This is a blocking call.%Receive a sys-ex response with time-out. This is a blocking call, and will wait until either the time-out expires or the message is received&UStart a thread to listen to the board and populate the channel with incoming queries.'cInitialize our board, get capabilities, etc. Returns True if initialization went OK, False if not. If ( , debugging info will be printedPath to the USB port%The Haskell controller program to run#$%&' #$%&' #$%&'(c) Levent ErkokBSD3erkokl@gmail.com experimentalNone!Retrieve the Firmata firmware version running on the Arduino. The first component is the major, second is the minor. The final value is a human readable identifier for the particular board."8Delay the computaton for a given number of milli-seconds#9Time a given action, result is measured in micro-seconds.$=Time-out a given action. Time-out amount is in micro-seconds.%-Set the mode on a particular pin on the board&'Set or clear a digital pin on the board'5Turn on/off internal pull-up resistor on an input pin(tRead the value of a pin in digital mode; this is a non-blocking call, returning the current value immediately. See )9 for a version that waits for a change in the pin first.)Wait for a change in the value of the digital input pin. Returns the new value. Note that this is a blocking call. For a non-blocking version, see (8, which returns the current value of a pin immediately.*tWait for a change in any of the given pins. Once a change is detected, all the new values are returned. Similar to )=, but is useful when we are watching multiple digital inputs.+Wait for any of the given pins to go from low to high. If all of the pins are high to start with, then we first wait for one of them to go low, and then wait for one of them to go back high. Returns the new values.,Wait for any of the given pins to go from high to low. If all of the pins are low to start with, then we first wait for one of them to go high, and then wait for one of them to go back low. Returns the new values.)A utility function, waits for any change on any given pin and returns both old and new values. It's guaranteed that at least one returned pair have differing values.-sSend down a pulse, and measure how long the pin reports a corresponding pulse, with a potential time-out. The call pulse p v duration mbTimeOut does the following:Set the pin to value v for duration microseconds.Waits 2 microsecondsWaits until pin p has value not v.7Returns, in micro-seconds, the duration the pin stayed v', counting from the 2 microsecond wait.&Time-out parameter is used as follows:If  mbTimeOut is Nothing, then - will wait until the pin attains the value required and so long as it holds it. Note that very-long time-out values are unlikely to be accurate.If  mbTimeOut is Just t then, - will stop if the above procedure does not complete within the given micro-seconds. In this case, the overall return value is Nothing.LNB. Both the time-out value and the return value are given in micro-seconds.UNB. As of March 2 2013; StandardFirmata that's distributed with the Arduino-App does notT support the Pulse-In command. However, there is a patch to add this command; see:  .http://github.com/rwldrn/johnny-five/issues/18- for details. If you want to use hArduino's pulseIn command, then you have4 to install the above patch. Also see the function pulseIn_hostOnly, which works with the distributed StandardFirmata: It implements a version that is not as accurate in its timing, but might be sufficient if high precision is not required..A hostOnly version of pulse-out on a digital-pin. Use this function only for cases where the precision required only matters for the host, not for the board. That is, due to the inherent delays involved in Firmata communication, the timing will notn be accurate, and should not be expected to work uniformly over different boards. Similar comments apply for / as well. See the function - for a more accurate version./A hostOnly version of pulse-in on a digital-pin. Use this function only for cases where the precision required only matters for the host, not for the board. That is, due to the inherent delays involved in Firmata communication, the timing will notn be accurate, and should not be expected to work uniformly over different boards. Similar comments apply for . as well. See the function - for a more accurate version.0Read the value of a pin in analog mode; this is a non-blocking call, immediately returning the last sampled value. It returns 0' if the voltage on the pin is 0V, and 1023$ if it is 5V, properly scaled. (See 2 for sampling frequency.)16Write a PWM analog value to a pin. The argument is an *, indicating the duty cycle. 0 means off; 255f means always on. Intermediate values will create a square wave on that pin with the given duty-cycle2Set the analog sampling interval, in milliseconds. Arduino uses a default of 19ms to sample analog and I2C signals, which is fine for many applications, but can be modified if needed. The argument should be a number between 10 and 16384; 10? being the minumum sampling interval supported by Arduino and 16383 being the largest value we can represent in 14 bits that this message can handle. (Note that the largest value is just about 16> seconds, which is plenty infrequent for all practical needs.)!"#$%&'()*+,)-.Pin to send the pulse on Pulse valueaTime, in microseconds, to signal beginning of pulse; will send the opposite value for this amount(Pulse duration, measured in microseconds/012!"#$%&'()*+,)-./012!"#$%&'()*+,)-./012(c) Levent ErkokBSD3erkokl@gmail.com experimentalNone+30An abstract symbol type for user created symbols+*Various control masks for the Hitachi44780,bit 0 Controls whether cursor blinks-bit 1 Controls whether cursor is on.bit 2 Controls whether display is on/bit 0 Controls left/right scroll0bit 1 Controls left/right entry mode1Commands understood by Hitachi2 Convert a command to a data-word3+Initialize the LCD. Follows the data sheet  4http://lcd-linux.sourceforge.net/pdfdocs/hd44780.pdf, page 46; figure 24.4*Get the controller associated with the LCD5$Send a command to the LCD controller6%Send 4-bit data to the LCD controller7dBy controlling the enable-pin, indicate to the controller that the data is ready for it to process.8Transmit data down to the LCD9IHelper function to simplify library programming, not exposed to the user.4_Register 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.)58Write a string on the LCD at the current cursor position6 Clear the LCD7 Send the cursor to home position8_Set 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.9Scroll 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. :.Scroll the display to the right by 1 character:kDisplay characteristics helper, set the new control/mode and send appropriate commands if anything changed;Update the display control word<Update the display mode word=$Convert the mask value to the bit no>Clear by the mask?Set by the mask;Do not blink the cursor<Blink the cursor=aHide the cursor. Note that a blinking cursor cannot be hidden, you must first turn off blinking.>Show the cursor?Turn 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.@Turn the display onA$Set writing direction: Left to RightB$Set writing direction: Right to LeftCTurn 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.)iHaving 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.D.Turn off auto-scrolling. See the comments for C@ for details. When turned off (which is the default), you will notQ see the characters at the end of your strings that do not fit into the display.E Flash contents of the LCD screenFCreate 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.JThe 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: e [ " " , "@ @" , " " , " " , "@ @" , " @@@ " , " " , " " ] G/Display a user created symbol on the LCD. (See F for details.)HAccess 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.WCheck 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).63@+,-./01ABCDEFGHIJ23456789456789::;<=>?;<=>?@ABCDE Flash countDelay amount (in milli-seconds)FGH" 3456789:;<=>?@ABCDEFGH"  46578CD9:AB<;>=@?3HGFE&3@+,-./01 ABCDEFGHIJ23456789456789::;<=>?;<=>?@ABCDEFGH(c) Levent ErkokBSD3erkokl@gmail.com experimentalNone& !"#$%&'()*+,-./012& %01&()*+,-/.2'"#$!(c) Levent ErkokBSD3erkokl@gmail.com experimentalNoneIVThe Texas-Instruments 74HC595 8-bit shift register with 3-state outputs. Data sheet:  .http://www.ti.com/lit/ds/symlink/sn74hc595.pdf.This is a versatile 8-bit shift-register with separate serial and register clocks, allowing shifting to be done while the output remains untouched. We model all control pins provided. Note that the enable and clear lines are negated.KChip Pin: 14: Serial inputL#Chip Pin: 13: Negated output-enableM0Chip Pin: 12: Register clock, positive triggeredN.Chip Pin: 11: Serial clock, positive triggeredO Chip Pin: 10: Negated clear-dataPXChip Pins: 15, 1-7, and 8: Sequence of output bits, connect only if reading is necessaryQ<A shift-register class as supported by the hArduino library.RCapacityS Display nameTData sheet (typically a URL)UInitialize the shift-registerV8Disable the output, putting it into high-impedance stateW=Enable the output, getting it out of the high-impedance stateXClear the contentsY)Push a single bit down the shift-registerZ2Store the pushed-in values in the storage register[Read the current value storedKGExecute action, followed by a simulated falling edge on the given clockIJKLMNOPQRSTUVWXYZ[KLIJKLMNOPQRSTUVWXYZ[QRSTUVWXYZ[IJKLMNOPIJKLMNOPQ RSTUVWXYZ[KL(c) Levent ErkokBSD3erkokl@gmail.com experimentalNone\4A servo motor. Note that this type is abstract, use ] to create an instance.M(The internal-pin that controls the servoN<Pulse-width (microseconds) for the minumum (0-degree) angle.OHPulse-width (microseconds) for the maximum (typically 180-degree) angle.]Create a servo motor instance. The default values for the min/max angle pulse-widths, while typical, may need to be adjusted based on the specs of the actual servo motor. Check the data-sheet for your servo to find the proper values. The default values of 544 and 2400B microseconds are typical, so you might want to start by passing 0 for both parameters and adjusting as necessary.^Set the angle of the servo. The argument should be a number between 0 and 180, indicating the desired angle setting in degrees.\PMNO]DPin controlling the servo. Should be a pin that supports SERVO mode.GPulse-width (in microseconds) for the minumum 0-degree angle. Default: 544.UPulse-width (in microseconds) for the maximum, typically 180-degree, angle. Default: 2400.^\]^\]^\PMNO]^(c) Levent ErkokBSD3erkokl@gmail.com experimentalNone _ Beat countsd$Musical notes, notes around middle-Cm6A piezo speaker. Note that this type is abstract, use n to create an instance.Q*The internal-pin that controls the speakerRTempo for the melodyn Create a piezo speaker instance.S5Convert a note to its frequency appropriate for PiezoT$Convert a duration to a delay amountoTurn the speaker offU'Keep playing a given note on the piezo:p$Play the given note for the durationq.Play a sequence of notes with given durations:rRest for a given duration:_`abcdefghijklmVQRn7Tempo. Higher numbers mean faster melodies; in general.BPin controlling the piezo. Should be a pin that supports PWM mode.SToUpqr_`abcdefghijklmnopqrmndefghijkl_`abcproq _`abcdefghijklmVQRnSToUpqr(c) Levent ErkokBSD3erkokl@gmail.com experimentalNoneM 3456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqr(c) Levent ErkokBSD3erkokl@gmail.com experimentalNonesRead the value of an analog input line. We will print the value on the screen, and also blink a led on the Arduino based on the value. The smaller the value, the faster the blink.The circuit simply has a 10K potentiometer between 5V and GND, with the wiper line connected to analog input 3. We also have a led between pin 13 and GND. nhttp://github.com/LeventErkok/hArduino/raw/master/System/Hardware/Arduino/SamplePrograms/Schematics/Analog.pngssss(c) Levent ErkokBSD3erkokl@gmail.com experimentalNonet<Blink the led connected to port 13 on the Arduino UNO board.Note that you do not need any other components to run this example: Just hook up your Arduino to the computer and make sure StandardFirmata is running on it. However, you can connect a LED between Pin13 and GND if you want to blink an external led as well, as depicted below: mhttp://github.com/LeventErkok/hArduino/raw/master/System/Hardware/Arduino/SamplePrograms/Schematics/Blink.pngtttt (c) Levent ErkokBSD3erkokl@gmail.com experimentalNoneuRead 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.tThe wiring is straightforward: Simply put a push-button between digital input 2 and +5V, guarded by a 10K resistor: nhttp://github.com/LeventErkok/hArduino/raw/master/System/Hardware/Arduino/SamplePrograms/Schematics/Button.pnguuuu (c) Levent ErkokBSD3erkokl@gmail.com experimentalNonevhTwo 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.jWiring is very simple: Up-button connected to pin 4, Down-button connected to pin 2, and a led on pin 13. ohttp://github.com/LeventErkok/hArduino/raw/master/System/Hardware/Arduino/SamplePrograms/Schematics/Counter.pngvvvv (c) Levent ErkokBSD3erkokl@gmail.com experimentalNonew'Sound travels 343.2 meters per second ( +http://en.wikipedia.org/wiki/Speed_of_soundd). 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 xPMeasure and display the distance continuously, as reported by an HC-SR04 sensor.GWiring: 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! phttp://github.com/LeventErkok/hArduino/raw/master/System/Hardware/Arduino/SamplePrograms/Schematics/Distance.pngwxwxwxwx (c) Levent ErkokBSD3erkokl@gmail.com experimentalNoneyNotes for jingle-bells. Expecting a nice rendering from this encoding on a piezo speaker would be naive.. However, it's still recognizable!zLPlay the jingle-bells on a PWM line, attached to pin 3. We use a tempo of 752; which is fairly fast. For a slower rendring try 150 or higher values.9The circuit simple has a piezo speaker attached to pin 3. mhttp://github.com/LeventErkok/hArduino/raw/master/System/Hardware/Arduino/SamplePrograms/Schematics/Piezo.pngyzyzyzyz #(c) Antoine R. Dumont, Levent ErkokBSD3erkokl@gmail.com experimentalNone{,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 ~ and n to indicate a letter and a word break so we can insert some delay between letters and words as we transmit.Morse code dictionary[Given a sentence, decode it. We simply drop any letters that we do not have a mapping for.7Given a morsified sentence, compute the delay times. A W+ value means turn the led on that long, a X# value means turn it off that long.CFinally, turn a full sentence into a sequence of blink on/off codesA 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. mhttp://github.com/LeventErkok/hArduino/raw/master/System/Hardware/Arduino/SamplePrograms/Schematics/Blink.png {|}~ {|}~ {|}~{|}~(c) Levent ErkokBSD3erkokl@gmail.com experimentalNone1Connections for a basic hitachi controller. See  ;http://en.wikipedia.org/wiki/Hitachi_HD44780_LCD_controllerX 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 khttp://github.com/LeventErkok/hArduino/raw/master/System/Hardware/Arduino/SamplePrograms/Schematics/LCD.pngThe happy glyph. See F' for details on how to create new ones.The sad glyph. See F' for details on how to create new ones.Access the LCD connected to Arduino, making it show messages we read from the user and demonstrate other LCD control features offered by hArduino.(c) Levent ErkokBSD3erkokl@gmail.com experimentalNone%There are 5 keys on the OSepp shield.The 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: Shttp://osepp.com/products/shield-arduino-compatible/16x2-lcd-display-keypad-shield/Initialize 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-pressedMNumber guessing game, as a simple LCD demo. User thinks of a number between 0 and 1000, and the Arduino guesses it.eEntry to the classing number guessing game. Simply initialize the shield and call our game function. (c) Levent ErkokBSD3erkokl@gmail.com experimentalNoneComputes 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.tThe wiring is straightforward: Simply put a push-button between digital input 2 and +5V, guarded by a 10K resistor: ohttp://github.com/LeventErkok/hArduino/raw/master/System/Hardware/Arduino/SamplePrograms/Schematics/PulseIn.pngSend 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: mhttp://github.com/LeventErkok/hArduino/raw/master/System/Hardware/Arduino/SamplePrograms/Schematics/Blink.png(c) Levent ErkokBSD3erkokl@gmail.com experimentalNoneIConnections for the Texas Instruments 74HC595 shift-register. Datasheet:  .http://www.ti.com/lit/ds/symlink/sn74hc595.pdfN. In our circuit, we merely use pins 8 thru 12 on the Arduino to control the K, W, M, N, and Oc lines, respectively. Since we do not need to read the output of the shift-register, we leave the bits field unconnected.,Seven-segment display demo. For each key-press, we display an equivalent pattern on the connected 7-segment-display. Note that most characters are not-mappable, so we use approximations if available. We use a shift-register to reduce the pin requirements on the Arduino, setting the bits serially.Parts:`The seven-segment digit we use is a common-cathode single-digit display, such as TDSG5150 ( *http://www.vishay.com/docs/83126/83126.pdf), or Microvity's IS121, but almost any such digit would do. Just pay attention to the line-connections, and do not forget the limiting resistors: 220 ohm's should do nicely.1The shift-register is Texas-Instruments 74HC595:  .http://www.ti.com/lit/ds/symlink/sn74hc595.pdf. Make sure to connect the register output lines to the seven-segment displays with the corresponding letters. That is, shift-registers Q_A) (Chip-pin 15) should connect to segment A; Q_B (Chip-pin 1) to segment B., and so on. We do not use the shift-register Q_H' (Chip-pin 9) in this design. thttp://github.com/LeventErkok/hArduino/raw/master/System/Hardware/Arduino/SamplePrograms/Schematics/SevenSegment.png(c) Levent ErkokBSD3erkokl@gmail.com experimentalNoneYControl a servo, by executing user requests of blade movement. We allow 3 user commands:l to swipe from angle-0 to 180;r to swipe from angle-180 to 0;Or any number between 0 to 180/, which puts the servo to the desired position.{Almost any servo motor would work with this example, though you should make sure to adjust min/max pulse durations in the ]o command to match the datasheet of the servo you have. In this example, we have used the HS-55 feather servo ( 2http://www.servocity.com/html/hs-55_sub-micro.html2), which has the values 600 to 2400 micro-seconds.To connect the servo to the Arduino, simply connect the VCC (red) and the GND (black) appropriately, and the signal line (white) to any SERVO capable pin, in this example we're using pin number 9: mhttp://github.com/LeventErkok/hArduino/raw/master/System/Hardware/Arduino/SamplePrograms/Schematics/Servo.png`Control a servo, as guided by the input read from a potentiometer. The set-up is similar to the  example above, except instead of querying the user for the angle, we use the readings from a potentiometer connected to analog input number 2. We used a 10 KOhm potentiometer, but other pots would work just as well too: shttp://github.com/LeventErkok/hArduino/raw/master/System/Hardware/Arduino/SamplePrograms/Schematics/ServoAnalog.pngY !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abbcdefghijklmnopqrstuvwxyz{|}~      ;      !"#$&%&'()*+, -./0123456789m34:;34<=>?@ABCDEFGHIJKLMNOPLQRSTUVWXYZ[\]^_t`abcdefeghhArdu_DvjRIVn9qcIGUMPfGVA9DP/System.Hardware.Arduino.Parts.SevenSegmentCodesSystem.Hardware.Arduino!System.Hardware.Arduino.Parts.LCD,System.Hardware.Arduino.Parts.ShiftRegisters#System.Hardware.Arduino.Parts.Servo#System.Hardware.Arduino.Parts.Piezo-System.Hardware.Arduino.SamplePrograms.Analog,System.Hardware.Arduino.SamplePrograms.Blink-System.Hardware.Arduino.SamplePrograms.Button.System.Hardware.Arduino.SamplePrograms.Counter/System.Hardware.Arduino.SamplePrograms.Distance2System.Hardware.Arduino.SamplePrograms.JingleBells,System.Hardware.Arduino.SamplePrograms.Morse*System.Hardware.Arduino.SamplePrograms.LCD/System.Hardware.Arduino.SamplePrograms.NumGuess,System.Hardware.Arduino.SamplePrograms.Pulse3System.Hardware.Arduino.SamplePrograms.SevenSegment,System.Hardware.Arduino.SamplePrograms.ServoSystem.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 SR_74HC595serialnEnablerClocksClocknClearmbBits ShiftRegistersizename dataSheet initializedisableenableclearpushstorereadServoattachsetAngleDurationWholeHalfQuarterEightNoteABCDEFGRPiezospeakersilenceplayNote playNotesrest analogValblinkbuttoncountermicroSecondsToCentimetersdistance jingleBellsmainMorseDitDahLBreakWBreakdictdecodemorsifytransmit morseDemohitachihappysadlcdDemoKeyKeyRightKeyLeftKeyUpKeyDown KeySelectosepp initOSeppnumGuess guessGame pulseInDemo pulseOutDemosr sevenSegmentservo servoAnalogmkDebugPrintershowByte showByteListshowBin getStringfromArduinoBytestoArduinoBytes word2Bytes bytes2WordsbaseGHC.BaseNothingGHC.WordWord8SysExCmdRESERVED_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$fShowBoardCapabilities$fShowResponse $fShowIPin $fShowPin $fShowPortpinModepinValue InternalPinpinNo DigitalPin userPinNo AnalogPinMixedPinsysExnonSysExpackageunpackageSysExunpackageNonSysExgetCapabilitiesghc-prim GHC.TypesFalsesendrecv recvTimeOut setupListenerTrue waitGenericIntHitachi44780Mask LCD_BLINKON LCD_CURSORON LCD_DISPLAYONLCD_ENTRYSHIFTINCREMENT LCD_ENTRYLEFTCmd getCmdValinitLCD getControllersendCmdsendData pulseEnablewithLCDupdateDisplayDataupdateDisplayControlupdateDisplayModemaskBit clearMasksetMaskLCD_INITIALIZELCD_INITIALIZE_ENDLCD_FUNCTIONSETLCD_DISPLAYCONTROLLCD_CLEARDISPLAYLCD_ENTRYMODESETLCD_RETURNHOMELCD_SETDDRAMADDRLCD_CURSORSHIFTLCD_SETCGRAMADDR fallingEdge$fShiftRegisterSR_74HC595servoPinminPulsemaxPulsepiezoPintempo frequencyintervalsetNote Data.EitherLeftRight