Keyboard based switches

Hi all, I have had Arduino for past two days, so that u can all understand how much time i have put in it. I am trying Arduino after I heard a few words from a friend. Now to my problem.

I have to submit a project which I could not continue without Arduino support. My project is simple. I need to Use the Windows Keyboard and mouse to capture the key input / mouse key and check what key it is.

Say for example the user presses the "p" on his keyboard. Now i need to first check what key the user has pressed and then make the light glow. So far i have only learned to setup the board and write the blink code.

I am famished, tired after coding and learning so much on javascript finally I have come here with heavy depression. I hate programming as a major now. Anyway keep things aside this is what i am looking forward. And now electronics too anyway hoping arduino will make my life easier

To use VC++ or VB or C# and build a windows app; which will have read and check for four buttons (now lets say the four buttons are 'P,O,I,U') now say when the user presses 'p' on keyboard arduino glows the led on pin 13, when the user presses and holds 'o' arduino runs my fan and when he lets go the fan switches off(i think a few looping stmt will take of that, and when he pressed another key say it turns on my motor, something like that.

But plz guide me to a strong study material or atleast guide me to accept key press from keyboard and turn on a few lights

I m so sorry to be cribbing in this forum but couldn't help it =(

Look in: File/Examples/Communication/Dimmer and SerialCallResponse I'm sure you can adapt it for your needs.

now where can i find the processing example so as to review it code

Thanx m8 ur lighting my day

Have you scroll a page down? It's included in sketches:

/* Processing code for this example // Dimmer - sends bytes over a serial port

Damn now i understand it but still need hel with processing too many boxes will giv it a try though and sorry for not seeing the code earlier

but still need hel with processing

You need hel with Processing, huh?

Have you tried over at http://processing.org/?

I am so happy today. After your help i have come up with this. Now I am able to turn on and switch off the led after 5 seconds. Below is the code but its very newbie kind of thing i understand but for a guy who spent 2 days with this i think i have done ok.

const int ledPin = 13;      // the pin that the LED is attached to it is digital coz i need a switch 

void setup()
{
  // initialize the serial communication:
  Serial.begin(9600);
  //getting rid of garbage
  Serial.flush(); 
  // initialize the ledPin as an output:
  pinMode(ledPin, OUTPUT);
}

void loop() 
{
  byte srinpt;
  int avl;
  
  // check if data has been sent from the computer:
  if (Serial.available()) 
  {
    avl = Serial.available();
    
    // read the most recent byte (which will be from 0 to 255):
    brightness = Serial.read();
    if (brightness == 'p')
     {
      Serial.print("The data is :");
      Serial.println(brightness, DEC); //jus for debugging
      Serial.print("The serial available is :");
      Serial.println(avl); //jus for debugging
      
      if(avl == 1) // to avoid unnecessary queue of right click
      {
       digitalWrite(13, HIGH);
       delay(5000);              // wait for 5 second
       digitalWrite(13, LOW);    // set the LED off
       Serial.flush();           // flush the buffers
      }
     }
  }
}

Thank you very much for the help on forums. Now for rest of the problem I need a circuit design which will allow me to run a series of fans based on the status of pin 13, any guides?

Good.
Check on “Arduino Notebook”, p.31 and 32.

ARDUINO_NOTEBOOKv6.pdf (349 KB)

I am guessing that the fans you have in mind would use more current than the arduino would want to handle, so my suggestion is that you investigate using a Relay to turn the fan on and off.

If you search this forum, arduino.cc and try googling I'm sure you will find descriptions of how to connect a Relay to pin 13 instead of the LED. I expect you will want to control a Transistor from pin 13, and to use that transistor to control the relay, and thus the fan.

[quote author=Paul Howells link=topic=53506.msg383631#msg383631 date=1298764847] I am guessing that the fans you have in mind would use more current than the arduino would want to handle, so my suggestion is that you investigate using a Relay to turn the fan on and off.

If you search this forum, arduino.cc and try googling I'm sure you will find descriptions of how to connect a Relay to pin 13 instead of the LED. I expect you will want to control a Transistor from pin 13, and to use that transistor to control the relay, and thus the fan. [/quote]

I'm sorry whats a relay and yes your guess was right.

Magician: Good. Check on "Arduino Notebook", p.31 and 32.

I could not comprehend it m8; i understand i need to do what page 31 says but what does page 31 say, My skill towards electronics is bare minimal. I understand a transistor(MOSFET) will do the job what can anyone explain in terms of construction so i can jus go buy the parts and fix it.

You have to read more books -); There is one more link, with a classes you can download and study. Not in one day , of course. http://todbot.com/blog/bionicarduino/ Class3 include information on transistors and motors.