Hello.
Thanks for the answer, now I'm working on finding the arduino resistor values.
daniel.stancu
@daniel.stancu
Best posts made by daniel.stancu
Latest posts made by daniel.stancu
-
RE: multiple buttons on one analog pin arduino
-
multiple buttons on one analog pin arduino
I have a problem with programming of an arduino, I want to link 32 push-buttons on one analogic pin on the arduino that communicate radio using NRF with domoticz system on which I have 32 relay's
Can someone help me with the code?
Until now I did
/**- The MySensors Arduino library handles the wireless radio link and protocol
- between your home built sensors/actuators and HA controller of choice.
- The sensors forms a self healing radio network with optional repeaters. Each
- repeater and gateway builds a routing tables in EEPROM which keeps track of the
- network topology allowing messages to be routed to nodes.
- Created by Henrik Ekblad henrik.ekblad@mysensors.org
- Copyright (C) 2013-2015 Sensnology AB
- Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
- Documentation: http://www.mysensors.org
- Support Forum: http://forum.mysensors.org
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- version 2 as published by the Free Software Foundation.
- DESCRIPTION
- Simple binary switch example
- Connect button or door/window reed switch between
- digitial I/O pin 3 (BUTTON_PIN below) and GND.
- http://www.mysensors.org/build/binary
*/
// Enable debug prints to serial monitor
#define MY_DEBUG// Enable and select radio type attached
#define MY_RADIO_NRF24
//#define MY_RADIO_RFM69#include <SPI.h>
#include <MySensors.h>
#include <Bounce2.h>#define CHILD_ID 3
#define CHILD_ID1 4#define BUTTON_PIN 3 // Arduino Digital I/O pin for button/reed switch
#define BUTTON_PIN1 4Bounce debouncer = Bounce();
int oldValue=-1;Bounce debouncer1 = Bounce();
int oldValue2=-1;// Change to V_LIGHT if you use S_LIGHT in presentation below
MyMessage msg(CHILD_ID,V_TRIPPED);
MyMessage msg1(CHILD_ID1,V_TRIPPED);
void setup()
{
// Setup the button
pinMode(BUTTON_PIN,INPUT);
pinMode(BUTTON_PIN1,INPUT);
// Activate internal pull-up
digitalWrite(BUTTON_PIN,HIGH);
digitalWrite(BUTTON_PIN1,HIGH);// After setting up the button, setup debouncer
debouncer.attach(BUTTON_PIN);
debouncer1.attach(BUTTON_PIN1);debouncer.interval(5);
debouncer1.interval(5);}
void presentation() {
// Register binary input sensor to gw (they will be created as child devices)
// You can use S_DOOR, S_MOTION or S_LIGHT here depending on your usage.
// If S_LIGHT is used, remember to update variable type you send in. See "msg" above.sendSketchInfo("ButoaneTest", "2.0");
present(CHILD_ID, S_LIGHT);
present(CHILD_ID1, S_LIGHT);
}int isOn = 0;
int isOn1 = 0;// Check if digital input has changed and send in new value
void loop()
{
debouncer.update();
// Get the update value
int value = debouncer.read();if (value != oldValue) {
if (value == HIGH) {
if (isOn == 0) {
isOn = 1;
} else {
isOn = 0;
}
send(msg.set(isOn));
}
oldValue = value;
}debouncer1.update();
// Get the update value
int value1 = debouncer1.read();if (value1 != oldValue2) {
if (value1 == HIGH) {
if (isOn1 == 0) {
isOn1 = 1;
} else {
isOn1 = 0;
}
send(msg1.set(isOn1));
}
oldValue2 = value1;
}
}