11 output devices

fernando meneses

base3

11_add an output device to a microcontroller board you’ve designed and program it to do something

In this activity I will develop a PCB for data entries, chose the RGB, because I think it could be useful for my final project, I’ll start with the PCB of Neil, here an image of the cutting PCB.

RGB-fer

rgb

Here another image, now with the components.

FullSizeRender-6

To schedule has used for Arduino, thinking particularly of how to control for the final project, here the steps:

1. Connections, in this case, from the ISP connect the data and power.

8

2. Make the bootloader, the steps detailed in the activity “7 embedded programming”, here an image of the bootloader completed.

0

3. In this case to load the code will use the Arduino IDE is simple, just go to the “File” menu and then “charged using programmer” image here:

1

We will use the example of code “Blink” It is important to remember that the outputs that connect to the data in our microprocessor, 0, 1 and 2. For this reason, by sending the code “0” only activates the RGB color “Red”, a video here in red.

By sending “1”, the only active RGB color “green”.

2

Here a video green.

And to send “2”, the RGB only activates the “blue” color.

3

Here is a video in blue.

In my case, I do not need color, so that passeth to another example of Neil, now I go to prepare a matrix of LEDs. The idea is to generate numbers from 1 to 12 with a matrix of 5 × 5. Here the diagram in Eagle.

array led

The plan for the final project is to make a PCB to control inputs and outputs, in this case the LED matrix is output, the microcontroller will be in the center plate. PNG cut here.

array copia

Here the plates ready for cutting and welding.

FullSizeRender

FullSizeRender_2

I will be used to program the IDE of Arduino, sending the data to control the LED matrix of 5 × 5, the code would look like.

  1. byte matrix[5][5]= {
  2. {1, 1, 1, 1, 1},
  3. {1, 1, 1, 1, 1},
  4. {1, 1, 1, 1, 1},
  5. {1, 1, 1, 1, 1},
  6. {1, 1, 1, 1, 1}
  7. };
  8. byte anodes[5] = {9,10,11,12,13}; // +pin
  9. byte cathodes[5] = {3,4,5,6,7}; // -pin
  10. byte i;
  11. void setPinTo5V(byte pin)
  12. {
  13. pinMode(pin, OUTPUT);
  14. digitalWrite(pin, HIGH);
  15. }
  16. void setPinToGND(byte pin)
  17. {
  18. pinMode(pin, OUTPUT);
  19. digitalWrite(pin, LOW);
  20. }
  21. void clearAllPins()
  22. {
  23. for(i=0;i<4;i++)
  24. {
  25. pinMode(anodes[i], INPUT);
  26. digitalWrite(anodes[i], LOW);
  27. pinMode(cathodes[i], INPUT);
  28. digitalWrite(cathodes[i], LOW);
  29. }
  30. }
  31. void setup()
  32. {
  33. }
  34. void loop()
  35. {
  36. for(i=0;i<5;i++)
  37. {
  38. clearAllPins();
  39. if(matrix[0][i]==1)
  40. setPinTo5V(anodes[0]);
  41. if(matrix[1][i]==1)
  42. setPinTo5V(anodes[1]);
  43. if(matrix[2][i]==1)
  44. setPinTo5V(anodes[2]);
  45. if(matrix[3][i]==1)
  46. setPinTo5V(anodes[3]);
  47. if(matrix[4][i]==1)
  48. setPinTo5V(anodes[4]);
  49. setPinToGND(cathodes[i]);
  50. delay(1);
  51. }
  52. }

And here the first tests.

 

_conclusion

After receiving the data, the most fun is to send data, in this activity, I learned that the microcontroller allow sending data, each pin becomes a door that sends messages high or low to a physical device, and basically that’s it, but it’s magic.

It is important to remember the microcontroller outputs data at the time of programming, and it is also very important to think that the physical device data is also received and as they are received.

In some code, I learned how to generate the matrix and to define the output pins, and clearly remember that many errors are caused by bad connections, physical or digital.

_files

Eagle-array
png-array
array-code
RGB.ai
RGB.png
videos
_
Original source: http://academy.cba.mit.edu/classes/output_devices/index.html

Contact:  fernando.meneses@udem.edu / fernandomeneses@nodolab.com /  f  /  in  /  g+ / b / vmx / w