ESTE: UART - Basic Interrupts

De MediaWiki do Campus São José
Ir para navegação Ir para pesquisar

This experiment is part of this project.

Here we are going to do an experiment to implement a real aplication with UART. The exercise proposed here is to implement a communication between two boards, namelly two Arduinos Uno. A led on the second arduino(slave board) will blink according to the data received from the first arduino(master board). Therefore we need to programm to types of code: one for the master(sender) board and one for the slave board(receiver). In order to understand all the concepts used in this experiment it is recommended to see at first the basic UART script.

Pseudo code

Let's begin with a solution. The pseudo code (actual coding is up to you) is below:

int main(void) {
    byte incomingByte;
    baud_rate = 9600;
    while(1) {
        led_off();
    }
    return 0;    
}
void serial_interrupt_event() {
    if (data_available_on_input_field()) {
        incomingByte = read_data_on_input_field();
        println(incomingByte);
        led_on();
    }
}

This pseudo-code has a comparison statement to check if there are data available on the input field of the serial monitor, i.e serial port. If so, the data available will be stored on the memory, printed - only for debuging- and the led will be lighted on.

Schematic

Fig. 1 Schematic of the circuit

Part List

  • 1 LED
  • 1 220 ohm resistor for the led
  • 1 Protoboard
  • 2 copper wires (tinned) or jumpers


Assembly

Fig. 2 Assembly of the circuit

Solutions

Tools

References