12. Output devices¶
assignment¶
individual assignment:¶
add an output device to a microcontroller board you've designed, and program it to do something
group assignment:¶
individual assignment:¶
I chose to do this assigment with the satchakit see Week 11 for more detail and to add a lcd (see also in week 11 for more detail)
i have made a board with kicad to connect the lcd instead of the protoboard.
After that i need to solder the compenants
her is the code to be able to communicate with the atmega328p made by arduino (see the week 11)
#include <LiquidCrystal.h> #define pinThermistor 14 //config du LCD const int rs = 7, en = 6, d4 = 5, d5 = 4, d6 = 3, d7 = 2; //adapter les pins (fait) LiquidCrystal lcd(rs, en, d4, d5, d6, d7); void setup() { // put your setup code here, to run once: // set up the LCD's number of columns and rows: lcd.begin(16, 2); // Print a message to the LCD. lcd.setCursor(0,0); lcd.print("Temperature "); } void loop(void) { uint8_t i; float average; // take N samples in a row, with a slight delay for (i=0; i< NUMSAMPLES; i++) { samples[i] = analogRead(pinThermistor); delay(100); } // average all the samples out average = 0; for (i=0; i< NUMSAMPLES; i++) { average += samples[i]; } average /= NUMSAMPLES; // convert the value to resistance average = 1023 / average - 1; average = SERIESRESISTOR / average; float steinhart; steinhart = average / THERMISTORNOMINAL; // (R/Ro) steinhart = log(steinhart); // ln(R/Ro) steinhart /= BCOEFFICIENT; // 1/B * ln(R/Ro) steinhart += 1.0 / (TEMPERATURENOMINAL + 273.15); // + (1/To) steinhart = 1.0 / steinhart; // Invert steinhart -= 273.15; // convert to C lcd.setCursor(0,1); lcd.print(steinhart); lcd.write(223); //symbole° lcd.print("C"); delay(500); }
Now here is the schema to connect the LCD
I have to be carefull to have the right pin connected to the lcd
See the code line for the LCD
That is the pin of the atmega328p
const int rs = 7, en = 6, d4 = 5, d5 = 4, d6 = 3, d7 = 2 LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
Now i have to connect my board atmega328p and my board for the lcd together and the lcd
developpent of my own board¶
see my final project to see my future Board