Week #3: Make-through
UART COMMUNICATION
UART COMMUNICATION
This is my make-through for the week's assignment.2 Grab a cup of coffee!
It is a great day to be in touch with others I have a secret want to tell you about. My friend is an alien he is From a planet called ARDUIVENUS∞ . I know him by accident as I found a black hole in my room he took to me by MORS code.HOW did this happen? I will tell you. he communicated with me by triggering led in my Arduino project to make it as MORS code. I didn't recognize this at first but after many trials, I found that I have an alien friend, I try to communicate with him by the same method so that I make a UART communication between my ATmega328 board as a slave and my ATtiny44 board as a master board each board has a mounted led onboard which will be triggered using a pushbutton .we make the led triggers to shape a MORS code which makes us able to communicate with each other.
including the software serial library in my code which helps to define the Tx and Rx pin in the Attiny
Assign Tx pin to pin 1 regarding ATtiny core
Assign Rx pin to pin 0
define the serial pins to be (RX,TX) and assign its name to be masterSerial (case sensItive name)
assign push button to pin 3 and give it a name (sw1)
assign led to pin 8 and give it a name (led1)
put the serial communication baud rate to be (9600) bit/sec
define the Rx pin as input pin which receive the coming data to the master
define the Tx pin as output pin which transmits data to the master board (ATmega board)
define the led1 as an output pin
define sw1 as an input pin
trigger the led1 to blink for 2 seconds then turn off and delay for 500 milliseconds to indicate that the code is running
making a condition that if the master switch is pushed then the master will send a number "1" to the slave which is the slave address , delay for 50 milliseconds then send the string s to the slave which mean blinking the led
if the switch is not bushed the master will send the slave address then send string " a" which mean turn off the led
using usbasb with a converter and VM cable to connect miso to miso , mosi to mosi, sck to sck, GND to GND and vcc to vcc which make us able to upload the code to our master board(ATtiny44) by the spi pin header as shown in the image
assign the name led1 to 7
assign the name device name to the character "1" which will be the address of the slave board
make a boolean called myID and assign it to be false
make a name called comingserial which will receive the coming data from the master
put the baud rate to be (9600) bit/sec which is the recommended rate
define led1 as an output pin
make led1 to blink for 2 second (2000 milliseconds )when power is connected
make a condition to check if there are a serial data between the two board
assign the variable comingserial to read the coming serial data
make a condition to check if the coming data is the device id or not
if the coming data is the device id then assign the variable myID to be true
then make a condtion to check if that the next coming data is the character" a" and myID become true then the slave will proceed the commend and turn on the led
if the coming serial is the character"s" which mean close the led and the variable myid is true then the slave will turn of the led and assign the variable myID to be false
using usbasb with a converter and VM cable to connect miso to miso , mosi to mosi, sck to sck, GND to GND and vcc to vcc which make us able to upload the code to the slave board(atmega328) by jumpers wire as shown in the image
What I learned this week is...
UART serial communication
i2c serial communication
Spi serial communication
the difference between serial and parallel communication
how to establish serial communication between master and slave board