Simulating a key press on Arduino Mega for software Resolume

Hi,

I am currently studying digital design and I need a little help with a project I want to achieve.
Indeed, I will make an interactive digital installation. In general, this system will consist of multiple boxes which can be pushed or pulled by a single user. Visual will then be projected above and evolve based on user choice.

For this I use the V-Jing software : Resolume for the mapping part and a Arduino Mega 2560 R3 card to give position moving information through small push buttons.

To link the information from the Arduino board button to Resolume software, I try to simulate the supports (typing) of a keyboard key which would launch a video.
For example, when a box would trigger the button 1, the virtual presses the button A to give information resolume launched a new visual.

My Arduino code for the button works is pretty simple I know :confused: but I'm really beginner in Arduino.

I tried to look for solutions on the forum but I did not really find any answers, I understand that the use of v-usb should be mandatory. I also thought passed through a MIDI keyboard if it would be easier (and Resolume is even better). Moreover, I am on Mac OSX but I think I will soon return to my Windows partition :slight_smile:

If anyone would know when a fairly simple way to similer support of a button in the Arduino code that would be really cool.

Thanks in advance. (and sorry for my english)

The main problem here is that we do not know what Resolume software is. You post no links.

Basically you communicate between the Arduino an a computer by sending serial messages or or bytes. The software on the computer then picks these up and does something with them. So your question is really how can your software pick up external serial input.

You mentioned MIDI, this is just serial data as well. If you have an application like hairless running on your computer this can convert serial from the Arduino into a MIDI stream for your software. Maybe that is the way to go as it is easy to send MIDI messages if your software can make nothing of them.

There is no need to switch to your Windows partition - don't go over to the Dark Side Luke.

I do not want to spend the dark side Obi Wan but I may not make me friends for help here haha.

Thank you for your answer !
Resolume is software to run the visual, it is very use to the "mapping" or link sound projects to images.
But its operation is not very important because I can associate a launch of "visual" in support of a button A for example.

Basically, I just want to be able to write in Arduino code when I press button 1 pretend I physically leaned on the letter A on my keyboard.

My code hoped is:

int button = 2;
int buttonState = 0;

void setup() {
  pinMode(button, INPUT);
}

void loop() {
  buttonState = digitalRead(button);
  if (buttonState == HIGH)
  {
    //Simulation of the physical touch of the letter A on the keyboard to launch a visual on Resolume
  }

  else
  {
    //Simulation of the physical touch of the letter B on the keyboard to launch a other visual on Resolume
  }
}

I hope to be clear :slight_smile:

Basically, I just want to be able to write in Arduino code when I press button 1 pretend I physically leaned on the letter A on my keyboard.

OK. This is not easy on an Arduino Uno but is very easy on an Arduino Leonardo or an Arduino Micro.

Here is some code that will print out a random phrase as if you had pressed the keys on a keyboard in response to a button push on the Arduino. Note it will not work on a Uno only a Arduino Leonardo or an Arduino Micro.

// Buzz phrase generator - Mike Cook May 2012
// For the Arduino Leonardo
// Ground pin 2 for a buzz word phrase to be typed in directly into your report

// add extra words in before the "0"
String word1[] = { "integrated ", "synchronised ", "responsive ", "parallel ", "balanced ", "total ", "functional ", "user friendly "
                   "optimal ", "compatible ","new ", "64-bit ","synergetic ","*"};
String word2[] = { "managerial ", "organisational ", "monitored ", "reciprocal ", "digital ", "logistical ", "transitional ",
                   "incremental ", "fifth generational ", "lifestyle ", "aspirational ", "*"};
String word3[] = { "policy ", "options ", "flexibility ", "capability ", "mobility ", "programming ", "concept ", "time phase ",
                    "projection ", "hardware ", "software ", "contingency ","*" };
  
int numberOfWords1=0,numberOfWords2=0,numberOfWords3 =0;
void setup() {
  // make pin 2 an input and turn on the 
  // pullup resistor so it goes high unless
  // connected to ground:
 pinMode(2, INPUT_PULLUP);
  Keyboard.begin();
  // find out how many words are in each array
  while(word1[numberOfWords1] != "*") numberOfWords1++;
  numberOfWords1--; // to make random number call correct
  while(word1[numberOfWords2] != "*") numberOfWords2++;
  numberOfWords2--;
  while(word1[numberOfWords3] != "*") numberOfWords3++;
  numberOfWords3--;
}

void loop(){
  while(digitalRead(2) == HIGH) { 
    // do nothing until pin 2 goes low
    delay(50);
    random(0,100); // just keep the random number ticking over
  }
  delay(100);
  
  Keyboard.print(word1[random(0,numberOfWords1)]);
  Keyboard.print(word2[random(0,numberOfWords2)]);
  Keyboard.print(word3[random(0,numberOfWords3)]);

// do nothing:
  while(digitalRead(2) == LOW);
  delay(100);
  while(digitalRead(2) == LOW); // get rid of any bounce
  delay(100);
}

I think you can hack it down to just produce one letter.

If not look up the key function here:-

OK thank you :slight_smile:
I'll try to watch this !

I also found this on my side.
It comes close to what I want to do.

No it doesn't it just sends bytes to the serial port, any idiot can do that. You want to have the bytes look like the computers keyboard sent them. With that code you need some program on your computer to read the serial data and inject it into the keyboard buffer.