Delta_G:
And if we could see that code we might be able to help you fix it.
#include <Bounce2.h>
/* This is a button program for the Sparkbooth
Software. When a button is pushed it will send
a key stroke to the PC via serial.write
and start the software. This is used in conjuction with ACC Key
http://www.aacinstitute.org/downloads/aackeys/AACKeys.html for
serial command input into the computer.
Code has been parse together from examaples from Shifter and Arduino.cc
*/
/* The circuit:
1 Arduino UNO R3
1 USB A-B Cable
2 10kohm Resistors
20 330ohm Resistors
2 10 Segment LED Bar
2 Arcade buttons from sparkfun
3 74HC595
*/
// Library used for the 74HC595 Shift Registers
#include <Shifter.h>
int SER_Pin = 8; //pin 14 on the 75HC595
int RCLK_Pin = 11; //pin 12 on the 75HC595
int SRCLK_Pin = 12; //pin 11 on the 75HC595
#define NUM_REGISTERS 2 //how many registers are in the chain //Will be switch to three
// Constants won't change
//const int btnStart = 2; //Red Arcade button to start the program
//const int btnColor = 3; //Blue Arcade button to change the picture to Color
#define btnStart 2
#define btnColor 3
// Variables that will change
#define LEDPIN 13
//int LEDPIN = 13; //LED Test pin
int ButtonState[] = {0}; // Variable for the State of the buttons. In and Array
//initaize shifter using the Shifter library
Shifter shifter(SER_Pin, RCLK_Pin, SRCLK_Pin, NUM_REGISTERS);
Bounce debStart = Bounce();
Bounce debColor = Bounce();
void setup() {
shifter.clear(); // clears of pins on shift regs
shifter.setAll(LOW); // sets all pins to LOW
shifter.write(); // writes to the shift regs
pinMode(btnStart, INPUT_PULLUP); // Sets btnStart to INPUT Mode
pinMode(btnColor, INPUT_PULLUP); // Sets btnColor to INPUT Mode
debStart.attach(btnStart);
debColor.attach(btnColor);
debStart.interval(50);
debColor.interval(1);
// pinMode(btnBW, INPUT); // Saved for later
pinMode(LEDPIN, OUTPUT); // Sets Pin 13 to LED Pin OUTPUT Mode
pinMode(SER_Pin, OUTPUT); // Sets Data Pin to OUTPUT Mode
pinMode(RCLK_Pin, OUTPUT); // Sets Latch Pin to OUTPUT Mode
pinMode(SRCLK_Pin, OUTPUT); // Sets Clock Pin to OUT OUTPUT Mode
Serial.begin(115200); // Start the serial tranmission
}
void loop() {
debStart.update();
debColor.update();
ButtonState[1] = debStart.read();
ButtonState[2] = debColor.read();
//ButtonState[1] = digitalRead(btnStart); // Sets the button state for the two buttons
//ButtonState[2] = digitalRead(btnColor);
shifter.clear(); // set all pins on the shift register chain to LOW
shifter.write(); // send changes to the chain and display them
digitalWrite(LEDPIN, LOW); // Shuts the LED Status pin off
// If the First button (Start) is pressed call function takePic
if (ButtonState[1] == LOW) { // This button is always HIGH until pushed then LOW
takePic();
}
}
// Function takePic will send the keystroke 'SPACE' to the computer
void takePic() {
digitalWrite(LEDPIN, HIGH);
Serial.write(32); // ASCII for 'SPACE'
digitalWrite(LEDPIN, LOW);
// Signal(); // Calls Function signal
}
// Function changeColor will send the keystroke 'CTRL+K' to the computer
void changeColor () {
digitalWrite(LEDPIN, HIGH);
// char KeyCommand = 77;
//char KeyCommand[] = {27,44,44,'control',107,46};
char KeyCommand[] = {
27,44,'c','o','m','b','i','n','e',44,'c','o','n','t','r','o','l',46,107,46 };
//char KeyCommand[] = {27,44,68 6f 6c 64,44,'control',107,46};
//char KeyCommand[] = {27,'hold,control,107.'};
Serial.println(KeyCommand);
digitalWrite(LEDPIN, LOW);
//delay(250);
}
This is giving the best results right now. How ever I am still getting two pushes of the button on my serial monitor.