Tasks:
Add an output device to a microcontroller board you've designed and program it to do something
ATmega328/P
. (ATmega328/P) library
. Then I add the component on schematic window.
// include the library code:
#include <LiquidCrystal.h >
// initialize the library by associating any needed LCD interface pin
// with the arduino pin number it is connected to
const int rs = 0, en = 1, d4 = 10, d5 = 7, d6 = 4, d7 = 5;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
void setup() {
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
// Print a message to the LCD.545454
lcd.print("BE HAPPY =)!");
delay(1000);
}
void loop() {
// scroll 13 positions (string length) to the left
// to move it offscreen left:
for (int positionCounter = 0; positionCounter < 13; positionCounter++) {
// scroll one position left:
lcd.scrollDisplayLeft();
// wait a bit:
delay(150);
}
// scroll 29 positions (string length + display length) to the right
// to move it offscreen right:
for (int positionCounter = 0; positionCounter < 29; positionCounter++) {
// scroll one position right:
lcd.scrollDisplayRight();
// wait a bit:
delay(150);
}
// scroll 16 positions (display length + string length) to the left
// to move it back to center:
for (int positionCounter = 0; positionCounter <; positionCounter++) {
// scroll one position left:
lcd.scrollDisplayLeft();
// wait a bit:
delay(150);
}
// delay at the end of the full loop:
delay(1000);
}
#define pin2 10
#define pin1 7
#define enable 9
void setup() {
pinMode(pin1, OUTPUT);
pinMode(pin2, OUTPUT);
pinMode(enable, OUTPUT);
delay(1000);
}
void loop() {
//Make motor turn in one direction with a speed of 500
digitalWrite(pin1,1);
digitalWrite(pin2,0);
analogWrite(enable,500);
delay(1000);
//Make the DC Motor stop
digitalWrite(pin1,0);
digitalWrite(pin2,0);
analogWrite(enable, 0);
delay(1000);
//Reverse the direction of rotation and make the motor go slower
digitalWrite(pin1,0);
digitalWrite(pin2,1);
analogWrite(enable, 50);
delay(1000);
}
I don`t face any problem in this assignment :)