https://www.scribd.com/document/374788499/Arduino-Nano-as-Keyboard d0,d,d!,d4 /"#$%&NN&N% () N(*$+ *his is the basic code or a ! ey setup with $s. *his wors 00 with the arduino 1icro, eonardo and 2no. & you want a controer or 1ania or other ames, 5ust add more pins to the const int ines, add them as &N62*+ in pin1ode, and initiaie the diitaead unction in the oop As an eampe, ets say you wanted to add the 1 ey as a new button. ;ou woud add this to the eistin code: const int button1 < => pin1ode?button1, &N62*@> i ?diitaead?button1@ << (@ B Keyboard.press?CmC@> D ese B Keyboard.reease?CmC@> D onCt oret to put them in the riht pace & they are outside the correct oop, it wonCt wor $N () N(*$+"/
EincudeFKeyboard.hG otherwise it wonCt wor.
//;ou N$$ this ine
const int ed < H> //*hese rename the pins to somethin more reconisabe, you donCt haIe to name them ie this, & 5ust do it or practicaity const int ed! < 4> const int buttonJ < 3> const int button < !> Ioid setup?@ commands ony once B pin1ode?ed, (2*62*@> output. pin1ode?ed!, (2*62*@> pin1ode?buttonJ, &N62*@> input. pin1ode?button, &N62*@>
//*his eecutes the net
Keyboard.bein?@> the eyboard. D
//*his aows contro oIer
//+et up the pins 4 and H as // //+et up the pins ! and 3 as //
Ioid oop?@ on as the Arduino is powered on. B i ?diitaead?buttonJ@ << (@ is actiIated, B Keyboard.press?CC@> diitarite?ed, L&%L@> D ese B Keyboard.reease?CC@> diitarite?ed, (@> D
i ?diitaead?button@ << (@ is actiIated, B Keyboard.press?CC@> diitarite?ed!, L&%L@> D ese B Keyboard.reease?CC@> diitarite?ed!, (@> D D bracet >@
//*his repeats the net commands as
//i the input reads that it
//press the CC ey. //turn the irst ed on.
//(therwise, //reease the CC ey. //turn the irst ed o.
//i the input reads that it
//press the CC ey. //turn the second ed on.
//(therwise, //reease the CC ey. //turn the second ed o. //onCt oret this itte