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
复制代码
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);