نحوه ارتباط nodemcu با ماژول بلوتوث HC_05
@micropython_iot
@micropython_iot
اسکریپت Lua برای ماژول بلوتوث
LEDpin = 4
gpio.mode(LEDpin, gpio.OUTPUT)--set LED pin as output pin
gpio.write(LEDpin, gpio.LOW)— set LED state initially low
—begin uart with specs
uart.setup(0, 9600, 8, uart.PARITY_NONE, uart.STOPBITS_1, 1)
—set callback function on receive to make decision about LED on/off
uart.on("data",1,
function(data)
if(data == "1") then
gpio.write(LEDpin, gpio.HIGH)
print("LED ON")
elseif(data == "2") then
gpio.write(LEDpin, gpio.LOW)
print("LED OFF")
else
print("select proper option")
end
end, 0)
نکته : پسورد دیفالت ماژول بلوتوث برای اتصال 0000 یا 1234 می باشد.
@micropython_iot
LEDpin = 4
gpio.mode(LEDpin, gpio.OUTPUT)--set LED pin as output pin
gpio.write(LEDpin, gpio.LOW)— set LED state initially low
—begin uart with specs
uart.setup(0, 9600, 8, uart.PARITY_NONE, uart.STOPBITS_1, 1)
—set callback function on receive to make decision about LED on/off
uart.on("data",1,
function(data)
if(data == "1") then
gpio.write(LEDpin, gpio.HIGH)
print("LED ON")
elseif(data == "2") then
gpio.write(LEDpin, gpio.LOW)
print("LED OFF")
else
print("select proper option")
end
end, 0)
نکته : پسورد دیفالت ماژول بلوتوث برای اتصال 0000 یا 1234 می باشد.
@micropython_iot
#جلسه_سوم
#میکرو_پایتون
راه اندازی ADC در میکرو پایتون!
جهت راه اندازی ADC (مبدل انالوگ به دیجیتال )
ابتدا کتابخانه Machine را فراخواتی میکنیم .
import machine
سپس پین adc مربوط به برد میکروپایتون خود را شناسایی کرده و آنرا در دستور زیر قرار دهید
adc=machine.ADC(machine.Pin(Pin number))
به جای عبارت Pin number شماره پین Adc برد خودرا وارد نمایید
و حال تابع adc.read را به نمایش بگذارید
Print(adc.read())
در نتیجه نسبت به ولتاژ وارده به پین که بین ۰ تا ۳.۳ باید باشد و اگر ولتاژ بالاتری از این حد دارید با تقسیم مقاومتی باید این ولتاژ را به ۳.۳ رسانده و به پین اعمال کنید . مقدار دیجیتال شده ولتاژ انالوگ وارده را مشاهده میکنید .
اسکریپت کامل 👇👇👇
#Micro Python ADC
#----------------------------------------
#Dev By Eng Meysam Mz
#----------------------------------------
#----------------
import machine
Import time
adc=machine.ADC(machine.Pin(36))
While 1:
print(adc.read())
time.sleep(1)
#-----------------
@Raspberryproject
@Raspberry_Python
@micropython_iot
#میکرو_پایتون
راه اندازی ADC در میکرو پایتون!
جهت راه اندازی ADC (مبدل انالوگ به دیجیتال )
ابتدا کتابخانه Machine را فراخواتی میکنیم .
import machine
سپس پین adc مربوط به برد میکروپایتون خود را شناسایی کرده و آنرا در دستور زیر قرار دهید
adc=machine.ADC(machine.Pin(Pin number))
به جای عبارت Pin number شماره پین Adc برد خودرا وارد نمایید
و حال تابع adc.read را به نمایش بگذارید
Print(adc.read())
در نتیجه نسبت به ولتاژ وارده به پین که بین ۰ تا ۳.۳ باید باشد و اگر ولتاژ بالاتری از این حد دارید با تقسیم مقاومتی باید این ولتاژ را به ۳.۳ رسانده و به پین اعمال کنید . مقدار دیجیتال شده ولتاژ انالوگ وارده را مشاهده میکنید .
اسکریپت کامل 👇👇👇
#Micro Python ADC
#----------------------------------------
#Dev By Eng Meysam Mz
#----------------------------------------
#----------------
import machine
Import time
adc=machine.ADC(machine.Pin(36))
While 1:
print(adc.read())
time.sleep(1)
#-----------------
@Raspberryproject
@Raspberry_Python
@micropython_iot
🌟اسکریپت Lua برای ماژول فرستنده nodemcu
uart.setup(1, 115200, 8, uart.PARITY_NONE, uart.STOPBITS_1, 1) — setup UART1 i.e. pin GPIO2
while true do —send string per second continuously
uart.write(1, "Hello friend\n")
tmr.delay(1000000)
end
🌟اسکریپت Lua برای ماژول گیرنده nodemcu
—callback on receiver data
uart.on("data","\n",function(data) print("receive from uart:", data) end, 0)
@micropython_iot
@raspberry_python
@raspberryproject
uart.setup(1, 115200, 8, uart.PARITY_NONE, uart.STOPBITS_1, 1) — setup UART1 i.e. pin GPIO2
while true do —send string per second continuously
uart.write(1, "Hello friend\n")
tmr.delay(1000000)
end
🌟اسکریپت Lua برای ماژول گیرنده nodemcu
—callback on receiver data
uart.on("data","\n",function(data) print("receive from uart:", data) end, 0)
@micropython_iot
@raspberry_python
@raspberryproject
Forwarded from C & micro & fpga
Forwarded from C & micro & fpga
Armstrong_Subero_auth_Programming.pdf
5.4 MB
Forwarded from C & micro & fpga
آموزش اتصال آردوینو به تلگرام.pdf
21.9 MB
آموزش اتصال آردوینو به تلگرام و کنترل رله👌
⚡️این جزوه در 60 صفحه تهیه شده است و دارای تصاویر از جزییات کار می باشد⚡️
@c_micro
⚡️این جزوه در 60 صفحه تهیه شده است و دارای تصاویر از جزییات کار می باشد⚡️
@c_micro
اسکریپت Lua برای ارتباط nodemcu و oled
sda = 2 — SDA Pin
scl = 1 — SCL Pin
s=0
m=0
h=0
function init_OLED(sda,scl) —Set up the u8glib lib
sla = 0x3C
i2c.setup(0, sda, scl, i2c.SLOW)
disp = u8g.ssd1306_128x64_i2c(sla)
disp:setFont(u8g.font_6x10)
disp:setFontRefHeightExtendedText()
disp:setDefaultForegroundColor()
disp:setFontPosTop()
—disp:setRot180() — Rotate Display if needed
end
function write_OLED() — Write Display
disp:firstPage()
repeat
disp:drawStr(50, 10, "Timer")
disp:drawStr(40, 30, string.format("%02d:%02d:%02d",h,m,s))
disp:drawStr(20, 50, "hello")
until disp:nextPage() == false
end
— Main Program
init_OLED(sda,scl)
tmr.alarm(0, 1000, 1, function() — Every second increment clock and display
s = s+1
if s==60 then
s=0
m=m + 1
end
if m==60 then
m=0
h=h + 1
end
if h==13 then
h=1
end
write_OLED()
end)
sda = 2 — SDA Pin
scl = 1 — SCL Pin
s=0
m=0
h=0
function init_OLED(sda,scl) —Set up the u8glib lib
sla = 0x3C
i2c.setup(0, sda, scl, i2c.SLOW)
disp = u8g.ssd1306_128x64_i2c(sla)
disp:setFont(u8g.font_6x10)
disp:setFontRefHeightExtendedText()
disp:setDefaultForegroundColor()
disp:setFontPosTop()
—disp:setRot180() — Rotate Display if needed
end
function write_OLED() — Write Display
disp:firstPage()
repeat
disp:drawStr(50, 10, "Timer")
disp:drawStr(40, 30, string.format("%02d:%02d:%02d",h,m,s))
disp:drawStr(20, 50, "hello")
until disp:nextPage() == false
end
— Main Program
init_OLED(sda,scl)
tmr.alarm(0, 1000, 1, function() — Every second increment clock and display
s = s+1
if s==60 then
s=0
m=m + 1
end
if m==60 then
m=0
h=h + 1
end
if h==13 then
h=1
end
write_OLED()
end)
Forwarded from C & micro & fpga