|
1-laboratory work
|
səhifə | 1/2 | tarix | 02.06.2023 | ölçüsü | 1,35 Mb. | | #122531 |
| Laboratoriya №7 OTvaUDT 2020 6
LABORATORIYA MASHG’ULOTI NOMI: O‘RNATILGAN TIZIMLARDA BLUETOOTH INTERFEYSI ORQALI MA’LUMOT UZATISH VA BOSHQARISH JARAYONINI LOYIHALASH
6-laboratoriya ishi
ISHNING MAQSADI: O’rnatilgan tizimlarda Bluetooth simsiz ma’lumot almashish interfeysi bilan ishlashni va jarayonni dastur yordamida boshqarishni o’rganish.
6-laboratoriya ishi
6-laboratoriya ishi
HC-05/06 Bluetooth modul - Ishchi chastotasi 2.4 – 2.48 GHz;
- Efir quvvati 0.25 – 2.5mW;
- Masofasi 10 m;
- Maksimal ma’lumot almashish tezligi 115200 bod;
- Manba 3.3V(tashqi 3.6-5V);
- Tok iste’moli 30-40 mA;
- Ishchi xarorati -25С dan 75С gacha.
5
6-laboratoriya ishi
ISHNI BAJARISH TARTIBI: - Namunada ko’rsatilgan ulanish sxemasini virtual (proteus, fritzing) muhit yordamida yoki real sharoitda yeg’ish;
- Quyida keltirilgan dastur kodini Arduino dasturlash muhitiga kiritib plataga yuklash.
6-laboratoriya ishi
Ulanish sxemasi
6-laboratoriya ishi
Dastur kodi
#include
#define RED_PIN 11
#define GREEN_PIN 10
#define BLUE_PIN 9
#define KEY_WORD "cmd:"
#define CMD_1 "power+"
#define CMD_2 "power-"
#define CMD_3 "red_on"
#define CMD_4 "red_off"
#define CMD_5 "green_on"
#define CMD_6 "green_off“
//….
SoftwareSerial ss(2, 3);
void setup() {
Serial.begin(9600);
ss.begin(9600);
pinMode(RED_PIN, OUTPUT);
pinMode(GREEN_PIN, OUTPUT);
6-laboratoriya ishi
Dastur kodi
pinMode(BLUE_PIN, OUTPUT); }
String recStr = "";
int power = 250;
void loop() {
if (Serial.available()) {
char ch = Serial.read();
Serial.write(ch);
if (ch == 0x0D || ch == 0x0A) {
if (recStr.startsWith(KEY_WORD)) {
String cmd = recStr.substring(4);
Serial.print("<<");
Serial.println(cmd);
if (cmd.equals(CMD_1)) {
power += 50;
if (power > 255) power = 255;
} else if (cmd.equals(CMD_2)) {
power -= 50;
if (power < 0) power = 0; }
6-laboratoriya ishi
Dostları ilə paylaş: |
|
|