Program a board to respond to keyboard?

The "Eleven" is our Uno-equivalent Arduino-compatible board, but with a number of improvements including prototyping area, a mini-USB connector, LEDs mounted near the edge, and the D13 LED isolated using a FET. [Product page]
Post Reply
zigon
Posts: 2
Joined: Wed May 27, 2015 10:40 am

Program a board to respond to keyboard?

Post by zigon » Wed May 27, 2015 10:49 am

Hi,
I am new to electronics and just bought myself an freetronics experimenters kit,
Just wondering if i can press a key on my keyboards and it will say turn the piezo on?
Or is this not possible.

Thanks,
Simon

andrew
Freetronics Staff
Freetronics Staff
Posts: 978
Joined: Sun Jul 14, 2013 7:06 am
Location: Melbourne, Australia
Contact:

Re: Program a board to respond to keyboard?

Post by andrew » Wed May 27, 2015 10:40 pm

Connect your piezo to D8 and try the following:

Code: Select all

void setup()  
{
  // set digital pin to control as an output
  pinMode(8, OUTPUT);
  // set the data rate for the Serial port
  Serial.begin(9600);
  // Send test message to PC
  Serial.println("Hello, world.");
}
char a; // stores incoming character from PC
void loop() 
{
  if (Serial.available())
  // if text arrived in from BT serial...
  {
    a=(Serial.read());
    if (a=='1')
    {
    tone(8, 493, 1000);
      Serial.println("on");
    }
  }
}
When you send the number '1' from the Serial monitor (or other software on your PC that can send text down the USB port) the Eleven will respond by making a tone for one second.

For more information on how Serial works, visit:
http://www.arduino.cc/en/Reference/Serial

zigon
Posts: 2
Joined: Wed May 27, 2015 10:40 am

Re: Program a board to respond to keyboard?

Post by zigon » Thu May 28, 2015 6:57 am

thanks :)

Post Reply