- •Practical embedded system programming
- •Void setup() {
- •In this firmware can be activated address bus a0, a1, a2 and a3
- •Void setup() {
- •Void setup() {
- •Void setup()
- •Void setup()
- •Void setup()
- •Void setup()
- •Void setup()
- •Void setup() {
- •Void setup(){
- •Void setup(){
- •Void setup()
- •Void setup()
- •Void setup()
- •Void setup()
- •Void setup()
- •Void setup() {
- •Void setup() {
- •Void setup(){
- •Void setup() {
- •Void setup() {
- •Void setup()
- •Void setup()
- •Void setup() {
- •Void setup() {
- •Void setup() {
- •Void setup() {
- •Void setup()
- •Void setup()
- •Void setup()
- •Void setup() {
- •Void setup() {
- •Void setup() {
- •Void setup() {
- •Void setup() {
- •Void setup() {
Void setup() {
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
}
void loop() {
// set the cursor to (0,0):
lcd.setCursor(0, 0);
// print from 0 to 9:
for (int thisChar = 0; thisChar < 10; thisChar++) {
lcd.print(thisChar);
delay(500);
}
// set the cursor to (16,1):
lcd.setCursor(16, 1);
// set the display to automatically scroll:
lcd.autoscroll();
// print from 0 to 9:
for (int thisChar = 0; thisChar < 10; thisChar++) {
lcd.print(thisChar);
delay(500);
}
// turn off automatic scrolling
lcd.noAutoscroll();
// clear screen for the next loop:
lcd.clear();
}
Write firmware for liquid-crystal display, using variables with pin modes as INT0; INT1; D4; D5; D6; D7; RS; E and so on.
//It is tested on Arduino IDE 1.0.5
int MCU_PD2_INT0 = 2;
int MCU_PD3_INT1 = 3;
int MCU_PD4_D4 = 4;
int MCU_PD5_D5 = 5;
int MCU_PD6_D6 = 6;
int MCU_PD7_D7 = 7;
const int LED_RS = 2;
const int LED_E = 3;
const int LED_DB4 = 4;
const int LED_DB5 = 5;
const int LED_DB6 = 6;
const int LED_DB7 = 7;
#include <LiquidCrystal.h> // adding library of liquid crystal display
LiquidCrystal lcd(LED_RS, LED_E, LED_DB4, LED_DB5, LED_DB6, LED_DB7); // (RS, E, DB4, DB5, DB6, DB7)
Void setup(){
Serial.begin(9600); //
lcd.begin(0, 0); // beginning of the sizes of liquid crystal display
lcd.setCursor(0, 0); // It sets the cursor of liquid-crystal display
lcd.print("God loves you"); // It displays characters and digits
}
void loop(){
}
Winking of the digits by the liquid crystal display:
/*
This firmware operates with microcontroller ATMEGA328P
This firmware can be debugged on the Arduino UNO R3
This firmware can be flashed by any professional programmer which supports a microcontroller ATMEGA328P
It operates with liquid crystal display LCD-1602
Designed by Dmitry
*/
//it configures device drivers:
#include<LiquidCrystal.h>
LiquidCrystal lcd(2, 3, 4, 5, 6, 7); //(RS, EN, D4, D5, D6, D7)
//it displays digits and characters:
unsigned char Input_number; //
Void setup() {
// put your setup code here, to run once:
Serial.begin(9600); //
lcd.setCursor(2, 4); //
lcd.begin(16, 2); //
lcd.print("1"); //
delay(1000); //
lcd.print("2"); //
delay(1000); //
lcd.print("3"); //
delay(1000); //
lcd.print("4"); //
delay(1000); //
lcd.print("5"); //
delay(1000); //
lcd.print("6"); //
delay(1000); //
lcd.print("7"); //
delay(1000); //
lcd.print("8"); //
delay(1000); //
lcd.print("9"); //
delay(1000); //
lcd.print("0"); //
delay(1000); //
lcd.print("#"); //
delay(1000); //
lcd.print("*"); //
delay(1000); //
lcd.println(Input_number); //
}
void loop() {
// put your main code here, to run repeatedly:
}
Winking of the relays
// Прошивка блока "А" исполнительных реле
String input_string = "";
Void setup() {
Serial.begin(9600);
pinMode(4, OUTPUT); //
pinMode(5, OUTPUT); //
pinMode(6, OUTPUT); //
pinMode(7, OUTPUT); //
pinMode(8, OUTPUT); //
pinMode(9, OUTPUT); //
pinMode(10, OUTPUT); //
pinMode(11, OUTPUT); //
digitalWrite(4,HIGH); //
digitalWrite(5,HIGH); //
digitalWrite(6,HIGH); //
digitalWrite(7,HIGH); //
digitalWrite(8,HIGH); //
digitalWrite(9,HIGH); //
digitalWrite(10,HIGH); //
digitalWrite(11,HIGH); //
}
void loop() {
while (Serial.available() > 0) {
char c = Serial.read();
if (c == '\n') {
// Дебаг
Serial.print("Input_string is: ");
Serial.println(input_string);
if (input_string=="a4off"){digitalWrite(4,HIGH);}
if (input_string=="a4on"){digitalWrite(4,LOW);}
if (input_string=="a5off"){digitalWrite(5,HIGH);}
if (input_string=="a5on"){digitalWrite(5,LOW);}
if (input_string=="a6off"){digitalWrite(6,HIGH);}
if (input_string=="a6on"){digitalWrite(6,LOW);}
if (input_string=="a7off"){digitalWrite(7,HIGH);}
if (input_string=="a7on"){digitalWrite(7,LOW);}
if (input_string=="a8off"){digitalWrite(8,HIGH);}
if (input_string=="a8on"){digitalWrite(8,LOW);}
if (input_string=="a9off"){digitalWrite(9,HIGH);}
if (input_string=="a9on"){digitalWrite(9,LOW);}
if (input_string=="a10off"){digitalWrite(10,HIGH);}
if (input_string=="a10on"){digitalWrite(10,LOW);}
if (input_string=="a11off"){digitalWrite(11,HIGH);}
if (input_string=="a11on"){digitalWrite(11,LOW);}
if (input_string=="test"){for (int i=4; i <= 11; i++){ digitalWrite(i,LOW); delay(1000);}
for (int i=4; i <= 11; i++){ digitalWrite(i,HIGH); delay(1000);}}
input_string = "";
} else {input_string += c;}
}
}
/*
Adafruit Arduino - Lesson 12. Light and Temperature
*/
#include <LiquidCrystal.h>
int tempPin = 0;
int lightPin = 1;
// BS E D4 D5 D6 D7
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);
