Mundarija:
Video: Magnit moslashuvchan qo'lli quyoshsiz simsiz chiroq: 8 qadam (rasmlar bilan)
2025 Muallif: John Day | [email protected]. Oxirgi o'zgartirilgan: 2025-01-13 06:58
Bu loyiha singan chiroq va nodeMCUdan qilingan. Ushbu dekorativ chiroqni har qanday yo'nalishda sozlash mumkin va magnit materiallarga yopishtirish yoki stolga qo'yish mumkin. U ikki rejimda boshqarilishi mumkin:
- Simsiz boshqaruv rejimi, quyida YouTube havolasi sifatida:
- Interaktiv boshqaruv rejimi, quyida YouTube havolasi sifatida:
1 -qadam: BILLIY MATERIALLAR
BOM ro'yxati:
Interaktiv rejim uchun, men NodeMCU -dan chiroq rangini boshqarish uchun gyro ma'lumotlarini olish uchun MPU6050 dan foydalanaman.
Loyiha uchun materiallar rasmlari:
2 -qadam: CIRCUIT
Bu juda oddiy sxema, yuqoridagi Fritzing sxemasida, 1 ta RGB Led umumiy anodli, uchta chegarali tok qarshilik R100 va MPU6050.
Reflektor har qanday singan lampalardan ishlatiladi va nodeMCU tagiga 2 ta murvat bilan ulanadi yoki ularni kuchli elim bilan yopishtiradi.
O'rnatish ishlari:
Quyidagi sxema:
3 -qadam: MAGNET BAZASI - FLEXIBLE ARM
Moslashuvchan qo'lni singan moslashuvchan suv kranlaridan qayta ishlatish mumkin. Shunga o'xshash narsa:
Ba'zi maslahatlar bilan biz ularni egiluvchan qo'lning pastki qismidagi doimiy magnitli tayanchga ulashga harakat qilamiz. Yuqorida biz elektron platamizga va quyosh batareyasi zaryadlovchisiga ulanish uchun burg'ulash teshigi qildik. Bu tayanch yordamida biz stolga, polga … kabi chiroqni qo'yishimiz mumkin. yoki uni temir ustun, po'lat konstruktsiya kabi magnit materiallarga biriktirish mumkin.
4 -qadam: KUNSLOR - BATAREYNI Zaryadlash
Bu shikastlangan zaryadlovchi chiroqdan kelgan. Men nodeMCU -ga yoqish/o'chirish tugmachasini va quvvat simlarini qo'shdim. Bundan tashqari, u bitta USB portli rozetkaga va bitta zaryadlovchi uchun vilkaga ega.
5 -qadam: BARCHA BIRGA ULANISH
Barcha qismlarni ulash: NodeMCU va reflektor, quyosh va batareya xujayralari, egiluvchan qo'l.
Tugatish
Zaryadlash rejimi
6 -qadam: INTERAKTIVLI NAZORAT DASTURI
Moslashuvchan qo'lni sozlashda yoki chiroqni aylantirishda rang o'zgaradi.
Interaktiv chiroq
#qo'shing |
// MPU6050 qul qurilmasi manzili |
const uint8_t MPU6050SlaveAddress = 0x68; |
// I2C aloqasi uchun SDA va SCL pinlarini tanlang - NODEMCU -dagi WIRE LIBRARY -da standart ko'rsatgichni belgilang: SCL - D1 va SDA - D2. |
// const uint8_t SCL = D1; |
// const uint8_t SDA = D2; |
const int R = 14; |
const int G = 12; |
const int B = 13; |
// MPU6050 konfiguratsiya registrining bir nechta manzili |
const uint8_t MPU6050_REGISTER_SMPLRT_DIV = 0x19; |
const uint8_t MPU6050_REGISTER_USER_CTRL = 0x6A; |
const uint8_t MPU6050_REGISTER_PWR_MGMT_1 = 0x6B; |
const uint8_t MPU6050_REGISTER_PWR_MGMT_2 = 0x6C; |
const uint8_t MPU6050_REGISTER_CONFIG = 0x1A; |
const uint8_t MPU6050_REGISTER_GYRO_CONFIG = 0x1B; |
const uint8_t MPU6050_REGISTER_ACCEL_CONFIG = 0x1C; |
const uint8_t MPU6050_REGISTER_FIFO_EN = 0x23; |
const uint8_t MPU6050_REGISTER_INT_ENABLE = 0x38; |
const uint8_t MPU6050_REGISTER_ACCEL_XOUT_H = 0x3B; |
const uint8_t MPU6050_REGISTER_SIGNAL_PATH_RESET = 0x68; |
int16_t AccelX, AccelY, AccelZ, harorat, GyroX, GyroY, GyroZ; |
bo'sh o'rnatish () { |
pinMode (R, OUTPUT); |
pinMode (G, OUTPUT); |
pinMode (B, OUTPUT); |
//Serial.begin (9600); |
Wire.begin (SDA, SCL); |
MPU6050_Init (); |
} |
void loop () { |
uint16_t Ax, Ay, Az, T, Gx, Gy, Gz; |
uint16_t qizil, yashil, ko'k; |
Read_RawValue (MPU6050SlaveAddress, MPU6050_REGISTER_ACCEL_XOUT_H); |
// Mutlaq qiymatni oling |
Ax = myAbs (AccelX); |
Ay = myAbs (AccelY); |
Az = myAbs (AccelZ); |
// Diapazonda o'lchov |
Qizil = xarita (Ax, 0, 16384, 0, 1023); |
Yashil = xarita (Ay, 0, 16384, 0, 1023); |
Moviy = xarita (Az, 0, 16384, 0, 1023); |
// Tekshirish uchun ketma -ket chop etish |
//Serial.print("Qizil: "); Serial.print (Qizil); |
//Serial.print("Yashil: "); Ketma -ket chop etish (yashil); |
//Serial.print("Moviy:"); Serial.print (Moviy); |
// LEDga analog yozing |
analogWrite (R, Qizil); // R. |
analogWrite (G, Yashil); // G. |
analogWrite (B, Moviy); // B |
kechikish (200); |
} |
yaroqsiz I2C_Write (uint8_t deviceAddress, uint8_t regAddress, uint8_t ma'lumotlar) { |
Wire.beginTransmission (deviceAddress); |
Wire.write (regAddress); |
Wire.write (ma'lumotlar); |
Wire.endTransmission (); |
} |
// Hamma 14 ta registrni o'qing |
bekor Read_RawValue (uint8_t deviceAddress, uint8_t regAddress) { |
Wire.beginTransmission (deviceAddress); |
Wire.write (regAddress); |
Wire.endTransmission (); |
Wire.requestFrom (deviceAddress, (uint8_t) 14); |
AccelX = ((((int16_t) Wire.read () << 8) | Wire.read ()); |
AccelY = ((((int16_t) Wire.read () << 8) | Wire.read ()); |
AccelZ = (((int16_t) Wire.read () << 8) | Wire.read ()); |
Harorat = (((int16_t) Wire.read () << 8) | Wire.read ()); |
GyroX = ((((int16_t) Wire.read () << 8) | Wire.read ()); |
GyroY = ((((int16_t) Wire.read () << 8) | Wire.read ()); |
GyroZ = ((((int16_t) Wire.read () << 8) | Wire.read ()); |
} |
// MPU6050 -ni sozlang |
bekor MPU6050_Init () { |
kechikish (150); |
I2C_Write (MPU6050SlaveAddress, MPU6050_REGISTER_SMPLRT_DIV, 0x07); |
I2C_Write (MPU6050SlaveAddress, MPU6050_REGISTER_PWR_MGMT_1, 0x01); |
I2C_Write (MPU6050SlaveAddress, MPU6050_REGISTER_PWR_MGMT_2, 0x00); |
I2C_Write (MPU6050SlaveAddress, MPU6050_REGISTER_CONFIG, 0x00); |
I2C_Write (MPU6050SlaveAddress, MPU6050_REGISTER_GYRO_CONFIG, 0x00); // +/- 250 daraja/soniyali to'liq o'lchov |
I2C_Write (MPU6050SlaveAddress, MPU6050_REGISTER_ACCEL_CONFIG, 0x00); // to'liq o'lchamli +/- 2g |
I2C_Write (MPU6050SlaveAddress, MPU6050_REGISTER_FIFO_EN, 0x00); |
I2C_Write (MPU6050SlaveAddress, MPU6050_REGISTER_INT_ENABLE, 0x01); |
I2C_Write (MPU6050SlaveAddress, MPU6050_REGISTER_SIGNAL_PATH_RESET, 0x00); |
I2C_Write (MPU6050SlaveAddress, MPU6050_REGISTER_USER_CTRL, 0x00); |
} |
// Mutlaq qiymat |
float myAbs (suzish) { |
qaytish (in)> 0? (in):-(in); |
} |
GitHub tomonidan ❤ mezbonlik qilingan rawINTERACTIVE LAMP PROGRAMINI ko'rish
7 -qadam: simsiz boshqaruv dasturi va ANDROID ilovasi
Boshqa usulda, biz Wi -Fi tarmog'ida Android bilan RGB LEDni boshqarish uchun Android ilovasidan foydalanishimiz mumkin. Android ilovasini bog'lang: NODEMCU RGB LED ilovasini boshqaradi
Arduino dasturi uchun siz quyidagilarga murojaat qilishingiz mumkin.
microcontrollerkits.blogspot.com/2016/05/es…
Dasturni NodeMCU -ga yuklaganingizdan so'ng, birinchi ishga tushirish bizga NodeMCU -ning IP -manzilini ketma -ket chop etishda beradi. Mening holimda: 80 portda 192.164.1.39.
Endi biz Internet Explorer -ga yuqoridagi manzilni kiritish orqali noutbuk/ planshet/ mobil telefon yordamida simsiz chiroqni boshqarishimiz mumkin.
Yoki Android ilovasidan foydalanib: