Replies: 3 comments 2 replies
-
What have you tried that didn't work? |
Beta Was this translation helpful? Give feedback.
0 replies
-
Hi,
thanks for the quick response.
I send you my Code, I don't know how i can "connect/patch" the Button "U1"
to Analog A5 for example, All at A0 are working fine.
Am Di., 16. Feb. 2021 um 22:05 Uhr schrieb Roberto Lo Giacco <
[email protected]>:
… What have you tried that didn't work?
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#17 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AS36AQBEHCX3CLVLMALFZMDS7LMZFANCNFSM4XW4F3PQ>
.
|
Beta Was this translation helpful? Give feedback.
2 replies
-
Hi,
I think i've done all, except *a2.check(); *I forgot that... Thank you, of
course it can't work without that line...
I try tomorrow in my workshop, if that was the problem, i just did all the
rest:
#include <AnalogButtons.h>
#include "Arduino.h"
#include "avdweb_Switch.h"
#include <DmxSimple.h>
#define DE_power 2
#define ANALOG_PIN A0
#define unlockPin A5
const byte toggleSwitchpin = 3;
const byte multiresponseButtonpin = 12;
const byte alleventsButtonpin = 13;
int unlock_state;
int b1_state = 0 ;
int b2_state = 0;
int latchPin = 7; // RCLK (Register Clock / Latch) Pin des 74HC595 ist
verbunden mit dem digitalen Pin 5
int clockPin = 6; // SRCLK (Shit Register Clock) Pin des 74HC595 ist
verbunden mit dem digitalen Pin 6
int dataPin = 5; // SER (Serial input) Pin des 74HC595 ist verbunden mit
dem digitalen Pin 4
byte leds = 0; // Hier speichern wir den Zustand der acht LEDs
AnalogButtons analogButtonsA0(ANALOG_PIN, INPUT_PULLUP);
Button b1 = Button(15, &b1Click, &b1Hold, 10000000000, 500000000);
Button b2 = Button(66, &b2Click, &b2Hold, 10000000000, 500000000);
Button b3 = Button(113, &b3Click, &b3Hold, 1000000000, 500000000);
Button b4 = Button(154, &b4Click, &b4Hold, 1000000000, 500000000);
Button b5 = Button(192, &b5Click, &b5Hold, 1000000000, 500000000);
Button b6 = Button(226, &b6Click, &b6Hold, 1000000000, 500000000);
Button b7 = Button(259, &b7Click, &b7Hold, 1000000000, 500000000);
Button b8 = Button(287, &b8Click, &b8Hold, 1000000000, 500000000);
Button b9 = Button(314, &b9Click, &b9Hold, 1000000000, 500000000);
Button b10 = Button(338, &b10Click, &b10Hold, 1000000000, 500000000);
Button b11 = Button(361, &b11Click, &b11Hold, 1000000000, 500000000);
Button b12 = Button(382, &b12Click, &b12Hold, 1000000000, 500000000);
AnalogButtons analogButtonsA5(unlockPin, INPUT_PULLUP);
Button U1 = Button(15, &U1Click, &U1Hold, 1000000000, 500000000);
void setup(){
Serial.begin(9600);
pinMode(latchPin, OUTPUT);
pinMode(dataPin, OUTPUT);
pinMode(clockPin, OUTPUT);
//pinMode(unlockPin, INPUT_PULLUP);
DmxSimple.usePin(4);
digitalWrite(DE_power, HIGH);
analogButtonsA0.add(b1);
analogButtonsA0.add(b2);
analogButtonsA0.add(b3);
analogButtonsA0.add(b4);
analogButtonsA0.add(b5);
analogButtonsA0.add(b6);
analogButtonsA0.add(b7);
analogButtonsA0.add(b8);
analogButtonsA0.add(b9);
analogButtonsA0.add(b10);
analogButtonsA0.add(b11);
analogButtonsA0.add(b12);
analogButtonsA5.add(U1);
}
void loop(){
// leds = 1;
analogButtonsA0.check();
// updateShiftRegister();
//unlock_state = digitalRead(unlockPin);
// configure();
if(b1_state == 0 && b2_state == 0){
bitClear(leds, 3);
bitClear(leds, 4);
bitClear(leds, 5);
bitClear(leds, 6);
DmxSimple.write(1,0);
DmxSimple.write(2,0);
DmxSimple.write(3,0);
DmxSimple.write(4,0);
updateShiftRegister();
}
if(b1_state == 1){
bitSet(leds, 3);
bitClear(leds, 5);
bitClear(leds, 6);
updateShiftRegister();
DmxSimple.write(1,255);
DmxSimple.write(2,0);
DmxSimple.write(3,0);
DmxSimple.write(4,10);
}
if(b1_state == 2){
bitSet(leds, 3);
bitSet(leds, 4);
bitClear(leds, 5);
bitClear(leds, 6);
updateShiftRegister();
DmxSimple.write(1,255);
DmxSimple.write(2,0);
DmxSimple.write(3,0);
DmxSimple.write(4,255);
}
if(b2_state == 1){
bitSet(leds, 5);
bitClear(leds, 3);
bitClear(leds, 4);
updateShiftRegister();
DmxSimple.write(1,50);
DmxSimple.write(2,127);
DmxSimple.write(3,50);
DmxSimple.write(4,0);
}
if(b2_state == 2){
bitSet(leds, 5);
bitSet(leds, 6);
bitClear(leds, 3);
bitClear(leds, 4);
updateShiftRegister();
DmxSimple.write(1,255);
DmxSimple.write(2,255);
DmxSimple.write(3,100);
DmxSimple.write(4,0);
}
}
void b1Click(){
Serial.println("button 1 clicked");
if(unlock_state == 0){
b1_state++;
b2_state = 0;
if(b1_state>=3) b1_state=0;
Serial.println(b1_state);
}
}
void b2Click() {
Serial.println("button 2 clicked");
if(unlock_state == 0){
b2_state++;
b1_state = 0;
if(b2_state>=3) b2_state=0;
Serial.println(b2_state);
}
}
void b3Click() {
Serial.println("button 3 clicked");
}
void b4Click() {
Serial.println("button 4 clicked");
}
void b5Click() {
Serial.println("button 5 clicked");
}
void b6Click() {
Serial.println("button 6 clicked");
}
void b7Click() {
Serial.println("button 7 clicked");
}
void b8Click() {
Serial.println("button 8 clicked");
}
void b9Click() {
Serial.println("button 9 clicked");
}
void b10Click() {
Serial.println("button 10 clicked");
}
void b11Click() {
Serial.println("button 11 clicked");
}
void b12Click() {
Serial.println("button 12 clicked");
b1_state++;
b2_state = 0;
if(b1_state>=3) b1_state=0;
}
void b1Hold(){}
void b2Hold(){}
void b3Hold(){}
void b4Hold(){}
void b5Hold(){}
void b6Hold(){}
void b7Hold(){}
void b8Hold(){}
void b9Hold(){}
void b10Hold(){}
void b11Hold(){}
void b12Hold(){}
void U1Click();{
Serial.println("U1 Clicked");
}
void U1Hold(){}
void updateShiftRegister(){
digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, LSBFIRST, leds);
digitalWrite(latchPin, HIGH);
}
void configure() {
unsigned int valueA0 = analogRead(ANALOG_PIN);
unsigned int valueA5 = analogRead(unlockPin);
Serial.println(valueA0);
Serial.println(valueA5);
delay(250);
}
Am Mi., 17. Feb. 2021 um 00:26 Uhr schrieb Roberto Lo Giacco <
[email protected]>:
… Have you tried anything along the lines of the following?
AnalogButtons a1(A1);
Button b1_1 = Button(1013, &b1_1Click);
Button b1_2 = Button(1002, &b1_2Click);
Button b1_3 = Button(970, &b1_3Click);
AnalogButtons a2(A2);
Button b2_1 = Button(1013, &b2_1Click);
Button b2_2 = Button(1002, &b2_2Click);
Button b2_3 = Button(970, &b2_3Click);
AnalogButtons a3(A3);
Button b3_1 = Button(1013, &b3_1Click);
Button b3_2 = Button(1002, &b3_2Click);
Button b3_3 = Button(970, &b3_3Click);
void setup() {
a1.add(b1_1);
a1.add(b1_2);
a1.add(b1_3)
a2.add(b2_1);
a2.add(b2_2);
a2.add(b2_3)
a3.add(b3_1);
a3.add(b3_2);
a3.add(b3_3);
}
void loop() {
// To check values when button are pressed
a1.check();
a2.check();
a3.check();
}
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#17 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AS36AQAOMYQJWO6WQKBFVKDS7L5KRANCNFSM4XW4F3PQ>
.
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello,
is it possible to use maybe two or three analog input pins, that i can seperate eight Buttons on each Pin (e.g. A0, A1, A2).
If Yes? How? I weren't able to do so.
greetings
Beta Was this translation helpful? Give feedback.
All reactions