2755 views|2 replies

1w

Posts

25

Resources
The OP
 

MicroPython controlling Arduino via 1-wire [Copy link]

 This is a library for controlling Arduino devices using MicroPython via a single bus protocol. Currently it supports the following commands:
  • pinMode
  • digitalWrite
  • digitalRead
  • analogWrite
  • analogRead
The communication uses CRC check to prevent communication errors.
链接已隐藏,如需查看请登录或者注册
  1. from arduinoGPIO.arduinoControl import ArduinoControl import machine import time arduinoControl = ArduinoControl(machine.Pin(19)) # 19: pin number of the 1-wire connection roms=arduino Control.scanSafely() # .scan() can be used too, this is just safer as it scans multiple times available_digital_pins=arduinoControl.digitalPins(roms[0]) available_analog_pins=arduinoControl.analogPins(roms[0]) arduinoControl.digitalWrite(roms[0], 13, 1) # led on time.sleep(2) ard uinoControl.digitalWrite(roms[0], 13, 0) # led off
复制代码
  1. from arduinoGPIO.arduinoControl import ArduinoControl from arduinoGPIO.arduino import Arduino import machine import time arduinoControl = ArduinoControl(machine.Pin(19)) # 19: pin number of the 1-wire connection roms=arduinoControl.scanSafely() # .scan() can be used too, this is just safer as it scans multiple times arduino = Arduino(arduinoControl, roms[0]) adc=arduino.ADC(0,vcc=3.3) # Analog pin 0. optional argument vcc used for calculating voltages print(adc.read()) print(adc.readVoltage()) led=arduinoControl.Pin(roms[0],13) led.on() time.sleep(1) led.off()[/ code] [b]Arduino[/b] [code]#include "OneWireHub.h" #include "Control.h" constexpr uint8_t pin_led {13}; constexpr uint8_t pin_onewire {2}; auto hub = OneWireHub(pin_onewire); #define UNIT_ID 0x03 //change this to be unique for every device in your 1-wire network auto arduino = Control(Control::family_code, 0x00,0x00,0xB2,0x18, 0xDA,UNIT_ID);
复制代码


Latest reply

Thanks for sharing!  Details Published on 2019-4-8 11:25
 
 

1w

Posts

25

Resources
2
 
Using a single bus, only VCC, DATA, and GND are needed to control multiple Arduinos and achieve function expansion and GPIO expansion.

 
 
 

173

Posts

0

Resources
3
 
Thanks for sharing!
Personal signature服务器大全
 
 
 

Guess Your Favourite
Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list