Mudanças entre as edições de "ESTE: UART - Basic Interrupts"

De MediaWiki do Campus São José
Ir para navegação Ir para pesquisar
Linha 40: Linha 40:
  
 
==Schematic==
 
==Schematic==
[[Arquivo:Uart_interrupt_basic_Esquemático.png|600px|thumb|center|Fig. 1 Schematic of the circuit]]
+
[[Arquivo:Uart_interrupt_basic_Esquemático.png|450px|thumb|center|Fig. 1 Schematic of the circuit]]
  
 
==Part List==
 
==Part List==

Edição das 09h07min de 15 de outubro de 2015

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 of the master an slave boards, respectively, is below:

//master  - sender
int main(void) {
   int num;
   baud_rate = 9600;
   while(1) {
        num = 0;
        println(num);
        delay_2000_ms();
        num = 1;
        println(num);
        delay_2000_ms();
    }
    return 0 ;
}
//slave - receiver
int main(void) {
   int byte_received = 0;
   int baud_rate = 9600;
   int led;
   while(1) {
       if (data_input_field > 0 ) {
           byte_received = read_data_on_input_field();
       }
       led = byte_received;
   }
   return 0;    
}

The master pseudo-code always varies a value to be send via the serial port. The slave pseudo-code has a comparison statement to check if the data_input_field is already filled and, if so, we know a data has been sent from the serial port and then the receiver board stores the data on the memory board and turns the led on or off according to the byte_received.

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