Inputbutton variable is the Arduino digital I/O pin where push button will be connected and depending upon its status, Data will be transmitted to master device. In this section we have included the SPI library and defined different variables. If the received data is 0, LED at pin 4 is set to LOW and if received data is 1, LED at pin 4 is set HIGH. Data is also received using the same function SPI.transfer. The next portion deals with the receiving of data. Depending upon status HIGH or LOW, command 1 or 0 is sent to slave using SPI.transfer function described above. Status of push button attached at pin 2 is read. Two variables are defined m_send and m_receive. In this section we have performed actual operation on instruction sending and receiving. Then SPI communication has been setup using functions described above and slave select has been set high to discontinue the communication if being performed already.ĭigitalWrite(SS,HIGH) Function performed The push and LED pins have been declared as input and output pins. Here device is being setup for program and communication. LED variable is the Arduino pin where based on data received from slave device output status will be shown. Push variables are the Arduino digital I/O pin where the push button will be connected and depending upon its status, Data will be transmitted to the slave device. In this section, we have included the SPI library and defined different variables. Arduino SPI Master Device CodeĬode can be divided into 3 parts: Declarations Now let us understand the code of the Master device.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |