Home
        V1.0a By Freezing Xie, Eric Pan Preface
         Contents
1.       Page 22 of 26 8 21 2009      WWW SEEEDSTUDIO COM  WY Seeed Studio Works   LSS Tech Support  info seeedi com    j    void loop    t    Serial print RTC get DS1307_HR true      read the hour and also update all the  values by pushing in true   Serial print         Serial print RTC get DS1307_ MIN  false     read minutes without update  false    Serial print         Serial print RTC get DS1307_SEC false     read seconds   Serial print          some space for a more happy life   Serial print RTC get DS1307_ DATE false     read date   Serial print         Serial print RTC get DS1307_MTH false     read month   Serial print         Serial print RTC get DS1307_ YR false      read year   Serial printIn       delay 1000      Press    serial monitor    button on the Arduino IDE  you can see the data returned by  RTC module     More information about IIC TWI library and RTC module is here   http   www arduino cc playground Learning I2C  http   www arduino cc en Reference Wire    http   www seeedstudio com depot electronic brick real time clock moduleds1307 p 491  html    Course 4     Interrupt    Interrupts are useful for making things happen automatically in microcontroller  programs  and can help solve timing problems  A good task for using an interrupt  might be reading a rotary encoder  monitoring user input     For an example  if you want to check the PIR sensor when displaying LCD  It may be    Page 23 of 26 8 21 2009      WWW SEEEDSTUDIO COM  WY Seeed Studio Works   OLSS Tec
2.      Arduino is based on flexible  easy to use hardware and software  These advantages make it became  one of the best choices for the MCU part of Electronic bricks  Each functional module has buckled  port with VCC  GND and Output  which has corresponding port on the adapter shields  with a plain  2 54mm dual female cable you may start playing already  Buckled brick cables are like cement to  make the connections easier  secure and more professional looking       Below catalog is for demonstration only  please visit depot for complete list    Micro controller units  MCU     MCU is the director of the circuits  as the core module for electronic bricks  You may use any  Arduino pin compatible boards  like Arduino Duemilanove  Seeeduino  Freeduino and etc     BOTRI G  a    a G  IY i pe F  URS sosog         WWW SEEEDSTUDIO COM  WY Seeed Studio Works   2282 Tech Support  info seeedi com    Electronic Brick shield    We provide two kind of Electronic Brick shields  Arduino Sensor Shield and Electronic Brick Chasis       Arduino Sensor shield V4 is a standard footprint Arduino shield  provided stackable pin headers    and 5 channel electronic brick connectivity  all digital and Analog IO are prepared with servo  compatibility     Easy  Reliable       Electronic Brick Series      Arduino Sensor Board See           Buckled  S ee ee ee i  Analog pe Arduino Port  Port   Ground     Vec  A0 A4 D Signal        Pr gital IO port DO D13  nS     Toe  2yf  Communication Port   BS   Selectable 
3.     home   Positions the cursor in the upper left of the LCD  That is  use that   location in outputting subsequent text to the display  To also clear the display  use    the clear   function instead     setCursor   Position the LCD cursor  that is  set the location at which  subsequent text written to the LCD will be displayed     Syntax      Icd setCursor col  row   write   Write a character to the LCD     Syntax      Icd write data     Page 16 of 26 8 21 2009      WWW SEEEDSTUDIO COM  WY Seeed Studio Works   LSS Tech Support  info seeedi com    print   Prints text to the LCD   Syntax  Icd print data     Icd print data  BASE   BASE  optional   the base in which to print  numbers  BIN for binary  base 2   DEC for decimal  base 10   OCT for octal   base 8   HEX for hexadecimal  base 16        include  lt LiquidCrystal h gt     include a library headfile     LiquidCrystal display with       rs on pin 10     rw on pin 11      enable on pin 12      d4  d5  d6  d7 on pins 13  14  15  16   LiquidCrystal Icd 10  11  12  13  14  15  16      void setup    t    Icd clear     clears the LCD and positions the cursor in the upper left corner  Icd print  hello  world       Print a message to the LCD   Icd setCursor 2 1      set to the 3th column and 2nd row    Icd print  Seeedstudio      Print a message to the LCD   j    void loop      t  j    More information about the LCE1602 and Library 1s here     http   www seeedstudio com depot Icd 162 characters green yellow back light p 62 h      
4.   WWW SEEEDSTUDIO COM  WY Seeed Studio Works OLSE Tech Support  info seeedi com      s  a  re         aS S      a       9                                45  Rs  O    Electronic Bricks Cookbook vol  1               gt   an     Be        V1 0a By Freezing Xie  Eric Pan    Preface    Should every child have played toy bricks  it is the most widely owned toy which help construct  preliminary inspirations easily  Easy plugging and dissemble  fast and robust  then creativity are  maximized by ignoring engineering difficulties     Similar to electronics for elder inventors  it may not be a problem after you have enough experience  and resource to make a prototyping from ground  But so much technical details usually distract the  inspirations  How about constructing electronic projects just like Lego brick     Yes  We can build electronics projects so easily  Arduino and its community have made the  programming much easier than ever before  Surely we need some elixir on hardware part  By using  electronic bricks  you may connect Arduino compatible boards easily with various digital  analog  and I2C Uart interfaces  These the breadboard less firm connection are prepared to extensive  modules like potentiometers  sensors  relays  servos   even buttons  just plug and play       WWW SEEEDSTUDIO COM  WY Seeed Studio Works OLSE Tech Support  info seeedi com    Intro    A basic setup of electronic bricks might include 5 parts  MCU boards  adapter shield  connectivity  and functional modules
5.  BUS3  D10 D13 D0 D1 A4 A5   D10 D13 are SPI  DO and D1 are RX TX  For SD card module       WWW SEEEDSTUDIO COM  WY Seeed Studio Works   2822 Tech Support  info seeedi com    Connectivities    While we recommend buckled cable for easy and firm connection  most 2 54 pitch cable could be  used on electronic brick connectors     Half buckled 3 wire cable  Fully buckled 3 wire cable    Compatible with V4 digital port  basic digital Firm connectivity on both ends  basic  module connections  Analog Digital module connections     Fully buckled 4 wire cable Fully buckled 10 wire bus cable    Firm connectivity on both ends  for I2C and Uart   Reverse proof  For ISP and data bus connections     connections     Quick plug terminal 2 wire Quick plug terminal 3 wire    Easy adaption of various circuits to electronic Easy adaption of various circuits to electronic  bricks interface  bricks interface          WWW SEEEDSTUDIO COM  WY Seeed Studio Works OLSE Tech Support  info seeedi com    Functional modules    Electronic bricks could be roughly classes by Input output Bus on usage  Or Digital Analog mixed on signal type     LED module  Used as digital IO to produce light  Buzzer module  Connect to PWM output for generating    analog IO to produce dimming lights  sound  or Analog input as piezo touch sensor     Relay module  Control high voltage circuit by 5V Button module  Simple basic momentary button for    logic digital output  input     PIR module  Detect human existence  output HIGH   
6.  tml    http   arduino cc en Reference LiquidCrystal    Course 3     IIC Interface     If you want Arduino to communication with external module  there are some  communication protocols optional  IIC  SPI and UART     See IIC   TWI for an example     Page 17 of 26 8 21 2009      WWW SEEEDSTUDIO COM  WY Seeed Studio Works   2282 Tech Support  info seeedi com    NXP Semiconductors developed a simple bi directional 2 wire bus for efficient  inter IC control  This bus is called the Inter IC or I2C bus  Only two bus lines are  required  a serial data line  SDA  and a serial clock line  SCL   Serial  8 bit oriented   bidirectional data transfers can be made at up to 100 kbit s in the Standard mode  up  to 400 kbit s in the Fast mode  up to 1 Mbit s in the Fast mode Plus  Fm    or up to  3 4 Mbit s in the High speed mode   Description from NXP I2C bus specification and  user manual v3      It   s not a must to know the specific protocol and time sequence  because there is a  ready library allows you to communicate with I2C   TWI devices  On most Arduino  boards  SDA  data line  is on analog input pin 4  and SCL  clock line  is on analog  input pin 5  On the Arduino Mega  SDA 1s digital pin 20 and SCL is 21  Let   s take a  quick look at the functions of the library     begin     begin address  Initiate the Wire library and join the I2C bus as a master or  Slave     address  the 7 bit slave address  optional   if not specified  join the bus as a master    note  There are both 7  and 
7.  when activated     Temperature sensing module  Output voltage Light sensing module  Output voltage changes       changes according to temperature  according to environmental light strength     wW Seeed Studio Works   2382    Tilt sensor module  Connect when tilting  disconnect    while horizontal     16 2 Character LCD  Display numeric and    characters  max 32 in a display     Sound sensing module  Output voltage changes    according to environmental sound strength     Accelerometer module  Output 3 axis acceleration    force by voltage     WWW SEEEDSTUDIO COM  Tech Support  info seeedi com    Rotary angle module  Output voltage changes    according to rotated angle     Joystick module  Joystick output 2 axis by analog  signal  press down as momentary button to output digital    pulse     Distance measurement module  Output voltage    changes according to distance detected     Keypad Module  3X3 scan keypad for input        Page 7 of 26 8 21 2009      WWW SEEEDSTUDIO COM  WY Seeed Studio Works   2282 Tech Support  info seeedi com    Electronic Brick 101    Course 0   Analog and Digital    Analog signals are continuous while digital signals are discrete  Analog signals are  continuously varying where digital signals are based on 0 s and I s  or as often  said        on s and off s   As an analogy  consider a light switch that is either on or off   digital  and a dimmer switch  analog  that allows you to adjust brightness  You may  check more details about Analog and digital 
8. 00        digitalWrite LED HIGH     turn on the light    j    else    t  digitalWri  te LED LOW      turn off the light    j  j    Result  It will turn the light on in darkness and turn off if bright enough     You can find more sensor brick here     http   www seeedstudio com depot electronic bricks c 44 html  Course 2     BUS    Most of the sensors and switches use a single wire for signal  There are modules need  more than one signal line  so we need the bus connection  Like the 16 2 Character  LCD module have 16 pins  there are 5 power pins and 11 signal pins  At least 10 pins  are needed to control the 16 2 Character LCD modules  so we need a bus to connect  it to Arduino     Hardware Setup  Connect the 16 2 Character LCD Brick with the 10pins cable to  the BUS2 connector of Chassis  And toggle the power switch to    On        Page 15 of 26 8 21 2009      WWW SEEEDSTUDIO COM  WY Seeed Studio Works   OLSS Tech Support  info seeedi com       We can use the library for Liquid Crystal to control the LCD easily  This library  allows an Arduino board to control Liquid Crystal displays  LCDs  based on most  popular Hitachi HD44780  or a compatible  chipset  The library works in either 4  or  8 bit mode   Software Setup    LiquidCrystal   Creates a variable of type Liquid Crystal    Syntax   LiquidCrystal rs  rw  enable  d4  d5  d6  d7    LiquidCrystal rs  rw  enable  d0  d1  d2  d3  d4  d5  d6  d7    clear  Clears the LCD screen and positions the cursor in the upper left corner
9. 3 are not prepared individually  but they are include in the Bus  1  So we need a BUS HUB module to break them out of BUS1  Connect the    Input     connector on the bus hub to    BUS1    connector on chassis by the 10 pins cable     Hardware Setup  Connector the PIR sensor to the    Pin2    connector on the bus hub   and connector the LED to the D8 connector on the chassis     Modify the code for interrupt     int PIR   0    define the 2th digital pin for PIR sensor brick interrupt  int LED   8    define the 8th digital pin for LED brick   int time 0     initial the time   void setup     i    pinMode LED  OUTPUT     set the LED pin for digital output  attachInterrupt PIR  blink  RISING      enable the interrupt   and when D2 rising jump into the  blink   function     void loop    i    Page 25 of 26 8 21 2009      WWW SEEEDSTUDIO COM  WY Seeed Studio Works   2282 Tech Support  info seeedi com    if  time gt 0     check if need to light the LED    i  digitalWrite LED HIGH      light the LED  time       decrease light time  j  else  i  digitalWrite LED LOW      turn off the LED  j  j  void blink    i  time 1000     catch the PIR sensor pulse  j    Program the code into the Arduino  When somebody detected by PIR sensor  the LED  will light for a moment     Revision History    21  Aug     V1 0a revision published    Page 26 of 26 8 21 2009    
10. 8 bit versions of I2C addresses  7 bits identify the  device  and the eighth bit determines if it s being written to or read from  The Wire  library uses 7 bit addresses throughout  If you have a datasheet or sample code that  uses 8 bit address  you ll want to drop the low bit  i e  shift the value one bit to the  right   yielding an address between 0 and 127      Syntax  wire begin 0x04      set a Arduino as a slave which address is 0x04   wire begin      set a Arduino as a master     requestFrom address  count  Request bytes from another device  The bytes may  then be retrieved with the available   and receive   functions  quantity  the number of  bytes to request     Syntax   wire requestFrom 0x04 4      A master request the slave which address is  0x04 to return 4 byte     beginTransmission address  Begin a transmission to the I2C slave device with the  given address  Subsequently  queue bytes for transmission with the send   function    and transmit them by calling endTransmission       Syntax  wire beginTransmissin 0x04     The master start a transmission with the slave  which address is 0x04    end Transmission   Ends a transmission to a slave device that was begun by  beginTransmission   and actually transmits the bytes that were queued by send       Page 18 of 26 8 21 2009      WWW SEEEDSTUDIO COM  WY Seeed Studio Works   2282 Tech Support  info seeedi com    Syntax  wire endTransmissin      The master ends a transmission with the slave which  connected     send   S
11. between   B  12C and Uart  3 j POWER avatos n     To Signal B  s bye ya   To vee 4 nae  as eae  To GND p   eee Arduino Port  Buckled Analog Port A5 Analog Port AO A5      Buckled Analog Port   Easy  Solid connection with Analog input with VCC GND     Bucked Communication Port   Easy communication port with 12C and Uart     Digital IO port   Standard servo pin compatible      Analog IO port   2 54 grid male pin header connections    NOY Seeed Studio Works   2832 WWW SEEEDSTUDIO COM    Tech Support  info seeedi com  Electronic Brick Chassis is dedicated for electronic brick setup  carrying much more electronic    brick connectors  even for data buses  It is more uniformed interface for beginners  on the other hand  provide super strong connection     D8   D12   D9   D11      Digital Input   Output  Analog Ouput     A1  A5   Analog InPut       Signal  vec  GND  BUSI BUS2 BUS3 Reset     Pin1  C  Pin 10  BUS 2  BUS    GYE 2 DBe 4  D3 4 D4 5 D5 EYE DIO EDHI    DI2 DIZ       UkGND 4   DG t DA iD   amp  D6 l0rGNWD GAG  amp   AZ TA  BLAI  BUS 3  I  VEC 2  D10 xI 4 D12    D13  SPI  DIO  SS  Dil  MOSI  DIZ  MISO  Dia  SCK       TkGND 9  DO t  DI TAS mAg    Chassis provides 5 Digital IO  5 analog input  1 IIC port and Uart serial port  The other 3 data buses  are prepared for more complex devices  These buses could be reprogrammed for other usages too     BUS1  D2 D8   for 4 4 keyboard by default   BUS2  D10 D17   D10 D13 are SPI  AO A3 could be used as D14 D17  For 16 2 LCD by default  
12. d receiveEvent int howMany     t  while 1  lt  Wire available       loop through all but the last    t  char c   Wire receive       receive byte as a character  Serial print c      print the character  j  int x   Wire receive       receive byte as an integer  Serial  println x      print the integer    j    Program this code into the other Arduino to turn it a receiver  then it become the slave  which address is 4  And press    serial monitor    button on the Arduino IDE  you can  see the data that slave received     There are many module have the IC interface  you can use the Arduino to control    them easily too  Let   s take the DS1307 RTC module for example  DS1307 1s a real  time clock IC  it can be set and sent out the clock data by IIC     Page 21 of 26 8 21 2009      WWW SEEEDSTUDIO COM  WY Seeed Studio Works OLS Tech Support  info seeedi com       Connect the RTC module to the IIC connector on chassis and program the code below   then you will get a clock      include  lt W Program h gt     include  lt Wire h gt     include  lt DS1307 h gt       written by mattt on the Arduino forum and modified by D  Sjunnesson    void setup     t  Serial begin 9600    RTC stopQ   RTC set DS1307_ SEC 1     set the seconds  RTC set DS1307_MIN 23     set the minutes  RTC set DS1307_ HR 12     set the hours  RTC set DS1307_DOW 4     set the day of the week  RTC set DS1307_DATE 5     set the date  RTC set DS1307_ MTH 3     set the month  RTC set DS1307_YR 9     set the year  RTC  start 
13. e called when a master requests data  from this slave device   handler  the function to be called  takes no parameters and    returns nothing  e g   void myHandler       Syntax  wire onRequest read      when the master receives a data from the slave it will  jump into the function read      Page 19 of 26 8 21 2009      WWW SEEEDSTUDIO COM  WY Seeed Studio Works   2822 Tech Support  info seeedi com       Let   s try connecting two Arduino together and communicate        Connect two Arduino with 4 pins cable use the IIC connector on the Chassis  Then the  hardware is set      include  lt Wire h gt     void setup     t  Wire begin       join 12c bus  address optional for master    j   byte x   0    void loop     t  Wire beginTransmission 4      transmit to device  4  Wire send  x is        sends five bytes  Wire send x      sends one byte  Wire endTransmission        stop transmitting  allies  delay 500      Page 20 of 26 8 21 2009      WWW SEEEDSTUDIO COM  WY Seeed Studio Works   2282 Tech Support  info seeedi com    j    Program this code into the first Arduino   then this one is the master  And we use it to  sent out data      include  lt Wire h gt     void setup     t  Wire begin 4      join 12c bus with address  4  Wire onReceive receiveEvent      register event  Serial begin 9600      start serial for output   j   void loop     t  delay 100     j       function that executes whenever data is received from master     this function 1s registered as an event  see setup    voi
14. e setup    int PIR 9    define the 9th digital pin for PIR sensor brick  int LED   8    define the 8th digital pin for LED brick  int time 0     initial the time    void setup     t  pinMode LED OUTPUT     set the LED pin for digital output  pinMode PIR INPUT     set the tilt sensor pin for digital input    j    void loop     if  digitalRead PIR      if check people move throw  i time   10000      set a light time  T  time gt 0     check if need to light the LED    t  digitalWrite LED HIGH      light the LED    time       decrease light time    j    else    t  digitalWrite LED LOW      turn off the LED    j  j    Page 12 of 26 8 21 2009      WWW SEEEDSTUDIO COM  WY Seeed Studio Works OLS Tech Support  info seeedi com    Result  when somebody detected by PIR sensor  the LED will light for a moment     More information about the PIR sensor is here     http   www seeedstudio com depot pir motion sensor module p 74 html        Illustration 1 2     The Analog sensor is different from Digital sensor  the level of analog signal  continuously reflect the factor been measured  like light strength  gas density   temperature and so on     Let   s take a Gas sensor for example  First  adjust the Resistor of the Brick to correct  the sensor output analog level  When power up the gas sensor will heat up  and then  we can adjust the resistor to about 5K correct the output analog signal to about 1V     Hardware Setup  Connect the Gas sensor brick to Al connector of the chassis  and  the buzz
15. ends data from a slave device in response to a request from a master  or  queues bytes for transmission from a master to slave device  in between calls to  beginTransmission   and endTransmission       Parameters  value  a byte to send  byte    string  a string to send  char      data  an array of data to send  byte      quantity  the number of bytes of data to transmit  byte     Syntax   wire send    hallow word          maser send up the data    hallow    to IIC bus     byte available   Returns the number of bytes available for retrieval with receive     This should be called on a master device after a call to requestFrom   or on a slave  inside the onReceive   handler  return the number of bytes available for reading     Syntax   if  wire available       check 1f there is data receive     byte receive   Retrieve a byte that was transmitted from a slave device to a master  after a call to requestFrom or was transmitted from a master to a slave     Syntax   data   receive       Retrieve the data that on the wire     onReceive handler  Registers a function to be called when a slave device receives a  transmission from a master   handler  the function to be called when the slave receives  data  this should take a single int parameter  the number of bytes received from the  master  and return nothing  e g   void     Syntax  wire onReceive read     when the slave receives a data from the master it  will jump into the function read      onRequest handler  Register a function to b
16. er to the D8 connector        Software Setup     int Gassensor 1    define the 1th digital pin for gss sensor brick  int Buzzer   8    define the 8th digital pin for buzzer brick    void setup      Page 13 of 26 8 21 2009      WWW SEEEDSTUDIO COM  WY Seeed Studio Works   2282 Tech Support  info seeedi com       pinMode Buzzer OUTPUT     set the LED pin for digital output  j    void loop     t  int val 0   val analogRead Gassensor     Read the gas sensor for gas density  if  val gt 0x300     if gas dense    t  digitalWrite Buzzer HIGH      ring the Buzzer for alarm  j  else  t  digitalWrite Buzzer LOW      turn off the buzzer  j    j    Result  If environmental gas density exceeds the value that we setup  the buzzer  will ring for alarm      Illustration 1 3     The light sensor is similar to gas sensor  it also outputdifferent level according to the  luminous intensity        Hardware Setup  Connect the light sensor brick to Al connector of chassis  and the  LED brick to D8 connector as a light source     Page 14 of 26 8 21 2009      WWW SEEEDSTUDIO COM  WY Seeed Studio Works   2282 Tech Support  info seeedi com    Software Setup     int LightSensor   1    define the 1th digital pin for light sensor brick  int LED   8    define the 8th digital pin for LED brick    void setup     t  pinMode LED OUTPUT     set the LED pin for digital output    j    void loop        int val 0    val analogRead LightSensor     Read analog level which match the luminous  intensity   if  val lt 0x2
17. h Support  info seeedi com    lost the PIR pulse signal when update the screen  The best way it   s use the Interrupt to  catch the small pulse  In the situations like this   using an interrupt can free the  microcontroller to get some other work done while not missing the input signal     Most Arduino boards have two external interrupts  numbers 0  on digital pin 2  and 1   on digital pin 3   The Arduino Mega has an additional four  numbers 2  pin 21   3   pin 20   4  pin 19   and 5  pin 18      And you can use the interrupt function to control the interrupt     attachInterrupt interrupt  function  mode   Specifies a function to call when an  external interrupt occurs  Replaces any previous function that was attached to the  interrupt     Parameters    Interrupt    is used to choose the external interrupt channel     Function    is  the function to call when the interrupt occurs  this function must take no parameters  and return nothing  This function is sometimes referred to as an interrupt service  routine     Mode    defines when the interrupt should be triggered  Four contestants are  predefined as valid values     LOW to trigger the interrupt whenever the pin is low   CHANGE to trigger the interrupt whenever the pin changes value  RISING to trigger when the pin goes from low to high     FALLING for when the pin goes from high to low     Page 24 of 26 8 21 2009      WWW SEEEDSTUDIO COM  WY Seeed Studio Works OLS Tech Support  info seeedi com       In chassis the D2 and D
18. ilt switch brick to D9 connector of chassis   and connect the LED brick to D8 connector  Then By tilting to different end  it works    like a switch     Software setup     Page 10 of 26 8 21 2009      WWW SEEEDSTUDIO COM  WY Seeed Studio Works   OLSS Tech Support  info seeedi com            f       A  i   gt      a     e    aN       int Mercury tilt 9    define the 9th digital pin for Mercury tilt switch brick  int Buzzer   8    define the 8th digital pin for LED brick  void setup      t  pinMode Buzzer  OUTPUT     set the LED pin for digital output    pinMode Mercury tilt  INPUT    set the tilt sensor pin for digital input  j    void loop      t  if  digitalRead Mercury_tilt      1f up tilt  digitalWrite Buzzer HIGH      ring the Buzzer  else    if not press  digitalWrite Buzzer LOW      turn off the Buzzer    j    Result  when the brick up tilt  the buzzer will alarm      Illustration 1 1     Some Digital sensor are not like a switch just to put out high or low level signal in  different situation  They put out pulse signal when activated     For PIR sensor  when people move into the range  it will send a high level pulse out   The pulse duration can be change by the resistance on the brick  It   s easier to check  pulses which lasts longer     Hardware Setup  Connect the PIR sensor brick to D9 connector of Chassis  and    Page 11 of 26 8 21 2009      WWW SEEEDSTUDIO COM  WY Seeed Studio Works   LSS Tech Support  info seeedi com    connect the LED brick to D8        Softwar
19. signals at Wikipedia     http   en wikipedia org wiki Analog signal     Illustration 0 0     Let   s try Digital signal first  The button or the digital sensor can be a digital input to  Arduino  Arduino can read these digital signals by the digital Pin  almost all the pin is  suppose digital input  And also can write the digital signal out by these digital Pins     Hardware setup  Now we use a button to control the LED on or off  What we need is  an Arduino  an Electronic Brick chassis  a button brick  LED brick and two signal  cables  Hook up the button Brick to the D9 connector of chassis  then the button 1s  connected with the 9    digital pin of Arduino  And hook up the LED Brick to the D8  connector of chassis  then the LED is connected with the 8  digital pin of Arduino        The hardware is set  and now we can open the Arduino IDE to prepare the sketch      Software setup     Page 8 of 26 8 21 2009      WWW SEEEDSTUDIO COM  WY Seeed Studio Works   OLSS Tech Support  info seeedi com    int Button   9    define the 9th digital pin for button brick  int LED   8    define the 8th digital pin for LED brick    void setup     t  pinMode LED OUTPUT     set the LED pin for digital output  pinMode Button  INPUT     set the Button pin for digital input    j   void loop     t  if  digitalRead Button      if button press  digitalWrite LED HIGH      light the LED  else    if not press  digitalWrite LED LOW      turn off the LED   j    Result  The LED will light whenever you press 
20. the button      Illustration 0 1     The Arduino can Read the Analog signal via the AD by the analog pin  and put  out the analog signal by PWM pins  In Arduino there are 6 analog input pin from  AO A1  and there are 6 analog output pins  D3 D5 D6 D9 D10 D11     Hardware Setup  We use a buzzer brick and a Rotary brick to demonstrate the  analog input and output  Connetct the buzzer to D9 connector and the rotary brick to  A1 connector of chassis        Page 9 of 26 8 21 2009      WWW SEEEDSTUDIO COM  WY Seeed Studio Works   OLSS Tech Support  info seeedi com    Software setup     int Rotary   1     define the Rotary for 1th Analog pin    int Buzzer   9     define the Buzzer for 9th Digital pin which is Analog out pin  also   int val   0    void setup     t   j   void loop     t    val   analogRead Rotary      read the Rotary analog value  analogWrite Buzzer val      Write the analog value out to Buzzer    Result  when you rotate the rotary brick  the buzzer sound will change   Course 1     Sensing the world    Sensors can be basically categorized as analog and digital  Some Digital sensor acts as  a switch  whenever triggered it output a    on    signal and the other environment it  output a    off    signal      Illustration 1 0     We take a Mercury tilt switch as an example  When the Mercury tilt switch brick is  tilted over a certain angle  it will be activated and send out a high level signal  else it  sent out a low level signal     Hardware Setup  Connect the Mercury t
    
Download Pdf Manuals
 
 
    
Related Search
    
Related Contents
Pulvérisateur à mousse  Trident Perseus A.M.S.  Moto X User Guide (UK)  T。s"ーBA 20ー ー` 06) 。。S 『グリーン購入法対象機種適合品』 ※施工上  User Guide Ioline FlexPlot  CHEOPS™ Model Documentation  Manual del usuario  PHANTOM 2 Product Release Notes  DBS-30.3 - Datatail  Datalogic Magellan 3200VSi    Copyright © All rights reserved. 
   Failed to retrieve file