arduino
Posted: Mon 06. Apr 2020 6:21:19
Witam,
Nie mogę sobie poradzić z konfiguracją przycisku ( button) tak aby po naciśnięciu pojawiał się stan wysoki w arduino. Z odczytami stanów wysokich i analogowych sobie poradziłem. Natomiast nie potrafię skonfigurować ( coil ) potrzebny jest skrypt? . Opierałem się na przykładzie programu dla arduino z Waszej strony.
Proszę o pomoc lub podanie przykładu.
Pozdrawiam
Marcin
#include <modbus.h>
#include <modbusDevice.h>
#include <modbusRegBank.h>
#include <modbusSlave.h>
modbusDevice regBank;
modbusSlave slave;
void setup()
{
pinMode(13, OUTPUT); //Declare LED as output
regBank.add(13); //Add Digital Output register
slave._device = ®Bank; //Assign the modbus device object to the protocol handler
slave.setBaud(9600); //Initialize the serial port for coms at 9600 baud
}
void loop()
{
int DO13 = regBank.get(13); //Digital output
if(DO13 <= 0 && digitalRead(13) == HIGH) digitalWrite(13,LOW);
if(DO13 >= 1 && digitalRead(13) == LOW) digitalWrite(13,HIGH);
slave.run();
}
Nie mogę sobie poradzić z konfiguracją przycisku ( button) tak aby po naciśnięciu pojawiał się stan wysoki w arduino. Z odczytami stanów wysokich i analogowych sobie poradziłem. Natomiast nie potrafię skonfigurować ( coil ) potrzebny jest skrypt? . Opierałem się na przykładzie programu dla arduino z Waszej strony.
Proszę o pomoc lub podanie przykładu.
Pozdrawiam
Marcin
#include <modbus.h>
#include <modbusDevice.h>
#include <modbusRegBank.h>
#include <modbusSlave.h>
modbusDevice regBank;
modbusSlave slave;
void setup()
{
pinMode(13, OUTPUT); //Declare LED as output
regBank.add(13); //Add Digital Output register
slave._device = ®Bank; //Assign the modbus device object to the protocol handler
slave.setBaud(9600); //Initialize the serial port for coms at 9600 baud
}
void loop()
{
int DO13 = regBank.get(13); //Digital output
if(DO13 <= 0 && digitalRead(13) == HIGH) digitalWrite(13,LOW);
if(DO13 >= 1 && digitalRead(13) == LOW) digitalWrite(13,HIGH);
slave.run();
}