[go: up one dir, main page]

0% found this document useful (0 votes)
25 views7 pages

CST-211 MiniProject Group 13

Download as docx, pdf, or txt
Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1/ 7

CST-211 Microcontroller Applications

Name: Mg Kaung Khant Lin


Roll No: YKPT-22334
Lab: CST-211 Microcontroller Applications (Miniprojects)
Email: kaungkhantlin@ucsy.edu.mm
Group: Group-13
Date: 15.2.2024

Sr. Name Roll No Email Remark


No
1 Thura Aung YKPT- 22352 thuraaung1@ucsy.edu.mm Leader

2 Kaung Khant Lin YKPT- 22334 kaungkhantlin@ucsy.edu.mm Member


3 Thuta Nyan YKPT- 22366 thutanyan@ucsy.edu.mm Member

4 Aung Kaung Myat YKPT- 22333 aungkaungmyat1@ucsy.edu.m Member


m

5 Thurein Htet YKPT- 22355 thureinhtet2@ucsy.edu.mm Member

6 Nyan Min Htet YKPT- 22319 nyanminhtet@ucsy.edu.mm Member

7 Nyan Htet Myat YKPT- 22335 nyanhtetmyat@ucsy.edu.mm Member

8 Naing Aung Lin YKPT- 22316 naingaunglinn@ucsy.edu.mm Member

9 Wyne Min YKPT- 21374 wyneminn@ucsy.edu.mm Member

Miniproject 1: Temperature sensor

1
CST-211 Microcontroller Applications

2
CST-211 Microcontroller Applications

const int temperaturePin = A0;


void setup() {
Serial.begin(9600);
}
void loop() {
float voltage, degreesC, degreesF;
getVoltage(temperaturePin);
degreesC = (voltage - 0.5) * 100.0;
degreesF = degreesC * (9.0 / 5.0) + 32.0;
Serial.print("voltage: ");
Serial.print(voltage);
Serial.print(" deg C: ");
Serial.print(degreesC);
Serial.print(" deg F: ");
Serial.println(degreesF);
delay(1000);
}
float getVoltage(int pin) {
return (analogRead(pin) * 0.004882814);
}

Miniproject 2: Motor

3
CST-211 Microcontroller Applications

const int motorPin = 9; // Connect the base of the transistor to pin 9.


void setup() {
pinMode(motorPin, OUTPUT);
Serial.begin(9600); // initialize Serial communications
}
void loop() {
int onTime = 3000; // milliseconds to turn the motor on
int offTime = 3000; // milliseconds to turn the motor off
analogWrite(motorPin, 255); // turn the motor on (full speed)
delay(onTime); // delay for onTime milliseconds
analogWrite(motorPin, 0); // turn the motor off
delay(offTime); // delay for offTime milliseconds
speedUpandDown();

4
CST-211 Microcontroller Applications

}
void speedUpandDown() {
int speed; int delayTime = 20; // milliseconds between each speed step // accelerate the motor
for(speed = 0; speed <= 255; speed++) {
analogWrite(motorPin,speed); // set the new speed
delay(delayTime); // delay between speed steps
} // decelerate the motor
for(speed = 255; speed >= 0; speed--) {
analogWrite(motorPin,speed); // set the new speed
delay(delayTime); // delay between speed steps
}
}
void serialSpeed() {
int speed;
Serial.println("Type a speed (0-255) into the box above,");
Serial.println("then click [send] or press [return]");
Serial.println();
while (Serial.available() > 0) {
speed = Serial.parseInt();
speed = constrain(speed, 0, 255);
Serial.print("Setting speed to "); // feedback and prints out the speed that you entered.
Serial.println(speed);
analogWrite(motorPin, speed); // sets the speed of the motor.
}
}
}

5
CST-211 Microcontroller Applications

Miniproject 3: LCD / Ultrasonic sensor HC-SR04

6
CST-211 Microcontroller Applications

LCD
#include < LiquidCrystal.h>
int seconds = 0;
lcd_1(12, 11, 5, 4, 3, 2);
void setup() {
lcd_1.begin(16, 2);
lcd_1.print("hello world!");
}
void loop() {
lcd_1.setCursor(0, 1); // print the number of seconds since reset: lcd_1.print(seconds);
delay(1000); // Wait for 1000 millisecond(s)
seconds += 1;
}
UltraSonic Sensor
int echoPin = 12;
long duration, cm, inches;
void setup() {
Serial.begin (9600);
pinMode(trigPin, OUTPUT); //Define inputs and outputs
pinMode(echoPin, INPUT);
}
void loop() {
digitalWrite(trigPin, LOW);
delayMicroseconds(5);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
}

You might also like