Hi Stefan,
A good night to think about it. And I decide to forget the autonomous project. I will try with a computer so (an apple computer in this case).
Is it possible to go on this way together?
Thank you.
Adafruit Neopixel and Bare Conductive Touch Board
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- yes_papa
- Posts: 64
- Joined: Tue Jan 21, 2014 7:08 am
- stefanbare
- Posts: 21
- Joined: Wed Mar 25, 2015 5:57 am
Re: Adafruit Neopixel and Bare Conductive Touch Board
Sounds good to me - keep in touch with how you get on!
S
S
- yes_papa
- Posts: 64
- Joined: Tue Jan 21, 2014 7:08 am
Re: Adafruit Neopixel and Bare Conductive Touch Board
So I will use two touch board systems. One touche board for each structure and so one computer for each system.
But it is perhaps possible to connect two touch board systems to only one computer. What do you think about it?
I think I will use GarageBand to affect the two sounds. Have you got another idea?
Could you recommend me a Bare Conductive Arduino project to start?
Thank you.
But it is perhaps possible to connect two touch board systems to only one computer. What do you think about it?
I think I will use GarageBand to affect the two sounds. Have you got another idea?
Could you recommend me a Bare Conductive Arduino project to start?
Thank you.
- stefanbare
- Posts: 21
- Joined: Wed Mar 25, 2015 5:57 am
Re: Adafruit Neopixel and Bare Conductive Touch Board
Hi again
I would suggest using the HID Keyboard code on the Touch Boards and Soundplant on the computer to trigger the sounds. Both boards can run from one computer. Just program each Touch Board with the HID code, but change the keymap on line 34 of HID_Keyboard.ino to map the keys differently. For example, instead of:
const char keyMap[12] = {'J', 'U', 'H', 'Y', 'G', 'T', 'F', 'D', 'E', 'S', 'W', 'A'};
You could have
const char keyMap[12] = {'1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '-', '='};
All the best
S
I would suggest using the HID Keyboard code on the Touch Boards and Soundplant on the computer to trigger the sounds. Both boards can run from one computer. Just program each Touch Board with the HID code, but change the keymap on line 34 of HID_Keyboard.ino to map the keys differently. For example, instead of:
const char keyMap[12] = {'J', 'U', 'H', 'Y', 'G', 'T', 'F', 'D', 'E', 'S', 'W', 'A'};
You could have
const char keyMap[12] = {'1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '-', '='};
All the best
S
- yes_papa
- Posts: 64
- Joined: Tue Jan 21, 2014 7:08 am
Re: Adafruit Neopixel and Bare Conductive Touch Board
Ok. The first objective with one touch board is completed: Play simultaneous sounds when we touch one or several pins.
It is working like a charm (ie I understand how to play the sound using the HID_Keyboard code on the Touch Boards and Soundplant on the computer).
Matching a pine with a key is pretty easy (just be careful with the AZERTY keyboard in my case).
So the next objective is to light the NeoPixel when a pin is used.
It is working like a charm (ie I understand how to play the sound using the HID_Keyboard code on the Touch Boards and Soundplant on the computer).
Matching a pine with a key is pretty easy (just be careful with the AZERTY keyboard in my case).
So the next objective is to light the NeoPixel when a pin is used.
- yes_papa
- Posts: 64
- Joined: Tue Jan 21, 2014 7:08 am
Re: Adafruit Neopixel and Bare Conductive Touch Board
Just a question to confirm: When we are working like that, we are not working on MIDI mode? It is not necessary to put the touch board on MIDI mode?
Thank you.
Thank you.
- yes_papa
- Posts: 64
- Joined: Tue Jan 21, 2014 7:08 am
Re: Adafruit Neopixel and Bare Conductive Touch Board
Hi Stefan,
Could you tell what I have to write to connect the DIN connector of the NeoPixel to the A0 Analog In of the Touch Board.
Thank You.
Could you tell what I have to write to connect the DIN connector of the NeoPixel to the A0 Analog In of the Touch Board.
Code: Select all
#include <Adafruit_NeoPixel.h>
#define N_LEDS 30 // Total number of LEDs in strip
#define LED_PIN (HERE) // NeoPixel strip is connected here
Adafruit_NeoPixel strip = Adafruit_NeoPixel(N_LEDS, LED_PIN, NEO_GRB + NEO_KHZ800);
- stefanbare
- Posts: 21
- Joined: Wed Mar 25, 2015 5:57 am
Re: Adafruit Neopixel and Bare Conductive Touch Board
Hi Stephane
1. MIDI mode is only for when the board is configured to use its own onboard MIDI synthesiser on the VS1053. For all other modes (MP3 playback, USB MIDI, USB HID etc...) you do not need this enabled.
2. Replace (HERE) with A0 in the code snippet you sent. The Adafruit Learning System is a great resource for learning about getting NeoPixels working with your board.
S
1. MIDI mode is only for when the board is configured to use its own onboard MIDI synthesiser on the VS1053. For all other modes (MP3 playback, USB MIDI, USB HID etc...) you do not need this enabled.
2. Replace (HERE) with A0 in the code snippet you sent. The Adafruit Learning System is a great resource for learning about getting NeoPixels working with your board.
S
- yes_papa
- Posts: 64
- Joined: Tue Jan 21, 2014 7:08 am
Re: Adafruit Neopixel and Bare Conductive Touch Board
Thank you for your confirmation.
I am already on the Adafruit Learning System resource. ;-)
I continue on the project.
Thank you.
I am already on the Adafruit Learning System resource. ;-)
I continue on the project.
Thank you.
- yes_papa
- Posts: 64
- Joined: Tue Jan 21, 2014 7:08 am
Re: Adafruit Neopixel and Bare Conductive Touch Board
Ok.
I have my NeoPixel script and I want to integrate if I touch the pin(N) or the pin(N+1) then I play this script(N).
Somebody has an idea to code this and is it correct?
Thank you.
I have my NeoPixel script and I want to integrate if I touch the pin(N) or the pin(N+1) then I play this script(N).
Code: Select all
void loop(){
// this is where we do all the real work
// only do anything if the overall touch status has changed
if(MPR121.touchStatusChanged()){
// update our touch data to ensure it is valid
MPR121.updateTouchData();
// run through all electrodes
for(int i=firstPin; i<=lastPin; i++){
if(MPR121.isNewTouch(i)){
// if we have a new touch on this electrode...
// turn the onboard LED on, and press (and release)
// the appropriate key on the "keyboard" output
digitalWrite(LED_BUILTIN, HIGH);
Keyboard.press(keyMap[i]);
Keyboard.release(keyMap[i]);
if(pin(0) and pin(1) are touched){
playTheScript(1);
}
if(pin(2) and pin(3) are touched){
playTheScript(2);
}
if(pin(4) and pin(5) are touched){
playTheScript(3);
}
} else if(MPR121.isNewRelease(i)){
// if we have a new release, turn the onboard LED off
digitalWrite(LED_BUILTIN, LOW);
}
}
}
}
Thank you.
- yes_papa
- Posts: 64
- Joined: Tue Jan 21, 2014 7:08 am
Re: Adafruit Neopixel and Bare Conductive Touch Board
Is it correct?
Perhaps it would be greater to use a "SWITCH" instruction?
Code: Select all
if(MPR121.isNewTouch(0) and MPR121.isNewTouch(1)){
strip.show();
}
- stefanbare
- Posts: 21
- Joined: Wed Mar 25, 2015 5:57 am
Re: Adafruit Neopixel and Bare Conductive Touch Board
Hi Stephane
Firstly, a lot of your code won't parse as correct C++ / Arduino code as it isn't syntactically correct. If you press the Verify (tick button) in the Arduino IDE, it will tell you if the code you have written is correct, and if not which line is incorrect. Please do this before posting code on forums - people don't take kindly to people asking whether code is correct or not if you haven't taken the time to use the tool provided which answers the exact question you are asking. For example, there is no "and" operator in C++/Arduino - you probably meant the boolean && operator. Also, the logic you are trying to implement in that snippet is incorrect, as what you describe is actually a boolean || (or).
I would strongly recommend using the Arduino Language Reference as a reference for valid functions / operators.
As for functional code - this is really down to you! Sadly, we can't write working code for all the projects out there. As a starting point, however, you might look at this:
Please take time to read this through and understand the logic before moving on with the project. The whole joy (and pain) of programming is understanding the algorithms that make the magic and how to implement them.
Firstly, a lot of your code won't parse as correct C++ / Arduino code as it isn't syntactically correct. If you press the Verify (tick button) in the Arduino IDE, it will tell you if the code you have written is correct, and if not which line is incorrect. Please do this before posting code on forums - people don't take kindly to people asking whether code is correct or not if you haven't taken the time to use the tool provided which answers the exact question you are asking. For example, there is no "and" operator in C++/Arduino - you probably meant the boolean && operator. Also, the logic you are trying to implement in that snippet is incorrect, as what you describe is actually a boolean || (or).
I would strongly recommend using the Arduino Language Reference as a reference for valid functions / operators.
As for functional code - this is really down to you! Sadly, we can't write working code for all the projects out there. As a starting point, however, you might look at this:
Code: Select all
void loop(){
// this is where we do all the real work
// only do anything if the overall touch status has changed
if(MPR121.touchStatusChanged()){
// update our touch data to ensure it is valid
MPR121.updateTouchData();
// run through all electrodes
for(int i=firstPin; i<=lastPin; i++){
if(MPR121.isNewTouch(i)){
// if we have a new touch on this electrode...
// turn the onboard LED on, and press (and release)
// the appropriate key on the "keyboard" output
digitalWrite(LED_BUILTIN, HIGH);
//Keyboard.press(keyMap[i]);
//Keyboard.release(keyMap[i]);
switch(i){
case 0:
case 1:
playTheScript(1);
break;
case 2:
case 3:
playTheScript(2);
break;
case 4:
case 5:
playTheScript(3);
break;
default:
break;
}
} else if(MPR121.isNewRelease(i)){
// if we have a new release, turn the onboard LED off
digitalWrite(LED_BUILTIN, LOW);
}
}
}
}
- yes_papa
- Posts: 64
- Joined: Tue Jan 21, 2014 7:08 am
Re: Adafruit Neopixel and Bare Conductive Touch Board
Thank Stefan for giving a way.
I know I have to confort my programming skill. I try to do it as fast as I can.
I just want to know if the logic was good. And it wasn't! ;-)
So I come back with a better code as soon as possible.
Thank for the tips too.
I know I have to confort my programming skill. I try to do it as fast as I can.
I just want to know if the logic was good. And it wasn't! ;-)
So I come back with a better code as soon as possible.
Thank for the tips too.
- yes_papa
- Posts: 64
- Joined: Tue Jan 21, 2014 7:08 am
Re: Adafruit Neopixel and Bare Conductive Touch Board
Ok. Here is the following.
When I play this code, I have a freeze on the NeoPixel. I can't see where the issue can come.
When I play this code, I have a freeze on the NeoPixel. I can't see where the issue can come.
Code: Select all
// neopixel includes
#include <Adafruit_NeoPixel.h>
// touch includes
#include <MPR121.h>
#include <Wire.h>
#define MPR121_ADDR 0x5C
#define MPR121_INT 4
// these keys map from E0 to E11 on the Touch Board - in GarageBand they map to a
// full chromatic scale (like a piano) from C to C - you can replace them with any
// keys you like - they don't even have to be letters
//
// take a look at http://arduino.cc/en/Reference/KeyboardModifiers for more keys
const char keyMap[12] = {'A', 'Z', 'E', 'R', 'T', 'Y', 'Q', 'S', 'D', 'F', 'G', 'H'}; //AZERTY version
//const char keyMap[12] = {KEY_LEFT_ARROW, KEY_RIGHT_ARROW, KEY_UP_ARROW, KEY_DOWN_ARROW, ' ', KEY_ESC, KEY_F1, KEY_F2, KEY_F3, KEY_F4, KEY_PAGE_UP, KEY_PAGE_DOWN};
// touch behaviour definitions
#define firstPin 0
#define lastPin 11
// define LED_BUILTIN for older versions of Arduino
#ifndef LED_BUILTIN
#define LED_BUILTIN 13
#endif
// neopixel definitions
#define TOTAL_LEDS 16 // Total number of LEDs in strip
#define PIN_LEDS A0 // NeoPixel strip is connected here
// Parameter 1 = number of pixels in strip
// Parameter 2 = Arduino pin number (most are valid)
// Parameter 3 = pixel type flags, add together as needed:
// NEO_KHZ800 800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
// NEO_KHZ400 400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
// NEO_GRB Pixels are wired for GRB bitstream (most NeoPixel products)
// NEO_RGB Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)
Adafruit_NeoPixel strip = Adafruit_NeoPixel(TOTAL_LEDS, PIN_LEDS, NEO_GRB + NEO_KHZ800);
// IMPORTANT: To reduce NeoPixel burnout risk, add 1000 uF capacitor across
// pixel power leads, add 300 - 500 Ohm resistor on first pixel's data input
// and minimize distance between Arduino and first pixel.
// Connect GND first, then Power and DIN
//Avoid connecting on a live circuit... if you must, connect GND first.
void setup(){
Serial.begin(57600);
pinMode(LED_BUILTIN, OUTPUT);
//while (!Serial) ; {} //uncomment when using the serial monitor
Serial.println("Bare Conductive HID keyboard demo");
Wire.begin();
if(!MPR121.begin(MPR121_ADDR)){
Serial.println("error setting up MPR121");
switch(MPR121.getError()){
case NO_ERROR:
Serial.println("no error");
break;
case ADDRESS_UNKNOWN:
Serial.println("incorrect address");
break;
case READBACK_FAIL:
Serial.println("readback failure");
break;
case OVERCURRENT_FLAG:
Serial.println("overcurrent on REXT pin");
break;
case OUT_OF_RANGE:
Serial.println("electrode out of range");
break;
case NOT_INITED:
Serial.println("not initialised");
break;
default:
Serial.println("unknown error");
break;
}
while(1);
}
MPR121.setInterruptPin(MPR121_INT);
MPR121.updateAll();
Keyboard.begin();
strip.begin();
strip.show(); // initialize all pixels to "off"
}
void loop(){
// this is where we do all the real work
// only do anything if the overall touch status has changed
if(MPR121.touchStatusChanged()){
// update our touch data to ensure it is valid
MPR121.updateTouchData();
// run through all electrodes
for(int i=firstPin; i<=lastPin; i++){
if(MPR121.isNewTouch(i)){
// if we have a new touch on this electrode...
// turn the onboard LED on, and press (and release)
// the appropriate key on the "keyboard" output
digitalWrite(LED_BUILTIN, HIGH);
Keyboard.press(keyMap[i]);
Keyboard.release(keyMap[i]);
switch(i){
case 0:
case 1:
Serial.print("playTheScript1"); // prints a label
Serial.print("\t"); // prints a tab
for (int NUM_LED=0; NUM_LED<TOTAL_LEDS; NUM_LED++) {
strip.setPixelColor(NUM_LED, 255, 255, 255);
}
strip.show(); //playTheScript(1)
delay(20);
break;
case 2:
case 3:
// print it out in many formats:
Serial.print("playTheScript2"); // prints a label
Serial.print("\t"); // prints a tab
for (int NUM_LED=0; NUM_LED<TOTAL_LEDS; NUM_LED++) {
strip.setPixelColor(NUM_LED, 255, 0, 255);
}
strip.show(); //playTheScript(2)
delay(20);
break;
case 4:
case 5:
// print it out in many formats:
Serial.print("playTheScript3"); // prints a label
Serial.print("\t"); // prints a tab
for (int NUM_LED=0; NUM_LED<TOTAL_LEDS; NUM_LED++) {
strip.setPixelColor(NUM_LED, 0, 255, 0);
}
strip.show(); //playTheScript(3)
delay(20);
break;
default:
Serial.print("playNothing"); // prints a label
Serial.print("\t"); // prints a tab
//strip.show(); //playNothing
//delay(20);
break;
}
} else if(MPR121.isNewRelease(i)){
// if we have a new release, turn the onboard LED off
digitalWrite(LED_BUILTIN, LOW);
}
}
}
}
- stefanbare
- Posts: 21
- Joined: Wed Mar 25, 2015 5:57 am
Re: Adafruit Neopixel and Bare Conductive Touch Board
Hi Stephane
Sorry - I am unable to help in this case. I can't see anything immediately wrong with your code, and since I am not in a position to support Neopixel products, you will have to take this up with Adafruit support.
All the best, and good luck with your project.
S
Sorry - I am unable to help in this case. I can't see anything immediately wrong with your code, and since I am not in a position to support Neopixel products, you will have to take this up with Adafruit support.
All the best, and good luck with your project.
S
Please be positive and constructive with your questions and comments.