<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Rajarshi Roy on Medium]]></title>
        <description><![CDATA[Stories by Rajarshi Roy on Medium]]></description>
        <link>https://medium.com/@rjrshr?source=rss-6804aa7112fd------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*AZN31JTacGVIw9KvDtgxbA.png</url>
            <title>Stories by Rajarshi Roy on Medium</title>
            <link>https://medium.com/@rjrshr?source=rss-6804aa7112fd------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 16:17:43 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@rjrshr/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Fun with Nixie Tubes]]></title>
            <link>https://medium.com/@rjrshr/nixie-tubes-f84f9db41bb1?source=rss-6804aa7112fd------2</link>
            <guid isPermaLink="false">https://medium.com/p/f84f9db41bb1</guid>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[hardware]]></category>
            <dc:creator><![CDATA[Rajarshi Roy]]></dc:creator>
            <pubDate>Tue, 03 Jan 2017 18:39:08 GMT</pubDate>
            <atom:updated>2017-01-04T03:54:32.064Z</atom:updated>
            <content:encoded><![CDATA[<p>I recently bought six IN-14 nixie tubes from e-bay and was immediately faced with the with the thought: “How am I gonna make these work?” Looking up over the internet, I found rather expensive nixie tube clock controllers and custom nixie tube controller boards. The biggest problem with them is the large pin-count and near 175 V needed to power them. After lots of time searching the net for nixie tube circuits I came up with an idea of a cheap modular nixie tube controller system. I even managed to have blue LEDs incorporated into this system. I am really happy how simple the circuitry turned out to be.</p><p>Once I get some male and female headers to get this modular and scalable system presentable for a youtube video, I shall post circuit diagrams, protoboard layout and step-by-step tutorial.</p><p>Here are some build pics (some of you will figure out the what to do just by looking at the pictures):</p><p>K155ID1 Nixie controller ICs:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/320/0*sSRFDMMX70XGabnZ.JPG" /></figure><p>Simple breadboard circuit components: (5v regulator, DC-DC boost converter, Nixie controller IC, IN-14 nixie tube)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/320/0*r7CAY__sQNIcCk14.JPG" /></figure><p>Simple breadboard circuit works!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/320/0*nWn-xjqxbBkZad34.JPG" /></figure><p>A single module of the system:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/320/0*xDo-SjWdkex2hJ2y.JPG" /></figure><p>Beautiful :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f84f9db41bb1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Arduino Based PC Ambient Lighting]]></title>
            <link>https://medium.com/@rjrshr/arduino-based-pc-ambient-lighting-bb370b0b64f1?source=rss-6804aa7112fd------2</link>
            <guid isPermaLink="false">https://medium.com/p/bb370b0b64f1</guid>
            <category><![CDATA[iot]]></category>
            <category><![CDATA[arduino]]></category>
            <dc:creator><![CDATA[Rajarshi Roy]]></dc:creator>
            <pubDate>Mon, 02 Jan 2017 18:30:39 GMT</pubDate>
            <atom:updated>2017-01-06T17:36:45.856Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Originally published at </em><a href="http://siliconrepublic.blogspot.com/2011/02/arduino-based-pc-ambient-lighting.html"><em>siliconrepublic.blogspot.com</em></a><em> on February 8, 2011.</em></p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FAm55k0k9eq8%3Ffeature%3Doembed&amp;url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DAm55k0k9eq8&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FAm55k0k9eq8%2Fhqdefault.jpg&amp;key=d04bfffea46d4aeda930ec88cc64b87c&amp;type=text%2Fhtml&amp;schema=youtube" width="640" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/059977bfd3724c03469e8885e68f430e/href">https://medium.com/media/059977bfd3724c03469e8885e68f430e/href</a></iframe><p>I really like the concept of ambient lighting systems which synchronize with entertainment to create a great immersive experience. And since I had a RGB led strip lying around I decided to use my Arduino and a Processing sketch to create such a system for computers which really turned out great!</p><p>Here is a video of my setup and a nice demo of it working with a Star Wars video clip:</p><p>Materials:If you would like to setup this system, it is quite simple and does not require any Arduino shields. The materials you will need other than an Arduino are:</p><p>+RGB LED Strip (&lt;=$15.95): You can get really cheap ones but I went with this Sparkfun LED strip due to ease of shipping (<a href="http://www.sparkfun.com/products/10261">http://www.sparkfun.com/products/10261</a>).</p><p>+ULN2003A (~$00.63): This chip is a transistor array for driving the LED strip which requires 12V signals with the 5V digital signals from the Arduino (order from DigiKey: <a href="http://www.digikey.com/">http://www.digikey.com</a>)</p><p><strong>Schematic:</strong>The LED driver circuit is extremely simplified due to the ULN2003A chip which eliminates the need for a separate transistor circuit for each R, G and B channel of the LED. Here is the schematic:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/0*H8S_r1tEmf0WATJr.png" /></figure><p>A closeup of my setup:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/0*rGxKCUJZ0NwHUZuj.JPG" /></figure><p><strong>Code:</strong></p><p>The system works by taking screenshots continuously and averaging the all the pixel colors. This data is then sent to the Arduino over USB. The Arduino receives this data and controls the LED strip color accordingly using pulse-width modulating each channel (Red, Green, Blue).</p><p><strong>Processing Code: </strong>(open Processing IDE: <a href="http://processing.org/">http://processing.org/</a>, copy-paste code, run)</p><pre>//Developed by Rajarshi Roy<br>import java.awt.Robot; //java library that lets us take screenshots<br>import java.awt.AWTException;<br>import java.awt.event.InputEvent;<br>import java.awt.image.BufferedImage;<br>import java.awt.Rectangle;<br>import java.awt.Dimension;<br>import processing.serial.*; //library for serial communication<br>Serial port; //creates object &quot;port&quot; of serial class<br>Robot robby; //creates object &quot;robby&quot; of robot class<br>void setup()<br>{<br>  port = new Serial(this, Serial.list()[0],9600); //set baud rate<br>  size(100, 100); //window size (doesn&#39;t matter)<br>  try //standard Robot class error check<br>  {<br>    robby = new Robot();<br>  }<br>  catch (AWTException e)<br>  {<br>    println(&quot;Robot class not supported by your system!&quot;);<br>    exit();<br>  }<br>}<br>void draw()<br>{<br>  int pixel; //ARGB variable with 32 int bytes where<br>  //sets of 8 bytes are: Alpha, Red, Green, Blue<br>  float r=0;<br>  float g=0;<br>  float b=0;<br>  //get screenshot into object &quot;screenshot&quot; of class BufferedImage<br>  BufferedImage screenshot = robby.createScreenCapture(new Rectangle(new Dimension(1368,928)));<br>  //1368*928 is the screen resolution<br>  int i=0;<br>  int j=0;<br>  //1368*928<br>  //I skip every alternate pixel making my program 4 times faster<br>  for(i =0;i&lt;1368; i=i+2){<br>    for(j=0; j&lt;928;j=j+2){<br>      pixel = screenshot.getRGB(i,j); //the ARGB integer has the colors of pixel (i,j)<br>      r = r+(int)(255&amp;(pixel&gt;&gt;16)); //add up reds<br>      g = g+(int)(255&amp;(pixel&gt;&gt;8)); //add up greens<br>      b = b+(int)(255&amp;(pixel)); //add up blues<br>    }<br>  }<br>  r=r/(684*464); //average red (remember that I skipped ever alternate pixel)<br>  g=g/(684*464); //average green<br>  b=b/(684*464); //average blue<br>  port.write(0xff); //write marker (0xff) for synchronization<br>  port.write((byte)(r)); //write red value<br>  port.write((byte)(g)); //write green value<br>  port.write((byte)(b)); //write blue value<br>  delay(10); //delay for safety<br>  background(r,g,b); //make window background average color<br>}</pre><p><strong>Arduino Code:</strong> (transfer this program to the Arduino)</p><pre>//Developed by Rajarshi Roy<br>int red, green, blue; //red, green and blue values<br>int RedPin = 9; //Red pin 9 has a PWM<br>int GreenPin = 10; //Green pin 10 has a PWM<br>int BluePin = 11; //Blue pin 11 has a PWM<br>void setup()<br>{</pre><pre>Serial.begin(9600);<br>  //initial values (no significance)<br>  int red = 255;<br>  int blue = 255;<br>  int green = 255;<br>}</pre><pre>void loop()<br>{</pre><pre>//protocol expects data in format of 4 bytes<br>  //(xff) as a marker to ensure proper synchronization always<br>  //followed by red, green, blue bytes<br>  if (Serial.available()&gt;=4) {<br>    if(Serial.read() == 0xff){<br>      red = Serial.read();<br>      green= Serial.read();<br>      blue = Serial.read();<br>    }<br>  }<br>  //finally control led brightness through pulse-width modulation<br>  analogWrite (RedPin, red);<br>  analogWrite (GreenPin, green);<br>  analogWrite (BluePin, blue);<br>  delay(10); //just to be safe<br>}</pre><p>I hope this project is easy to understand and setup. And even if you do not intend to set up this system, I hope the code and circuit shows some concept that you will find useful for other projects :) Comments are highly appreciated and my ears are open to any new ideas!</p><p><strong>Followup:</strong></p><p>I am truly truly amazed by the reception of this project and I feel extremely encouraged to put up more such projects in the future :D I am truly grateful for your support!</p><p>Here is a image of a simplified layout and connections (slightly modified from the original post in terms of which Arduino pin corresponds to R, G, B):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/0*BbodTMOfVC8JKmbq.JPG" /></figure><p>Also, I slightly modified the Arduino code to reflect the changes in the pin numbering:</p><pre>//Developed by Rajarshi Roy<br>int red, green, blue; //red, green and blue values<br>int RedPin = 10; //Red: PWM pin 10<br>int GreenPin = 11; //Green: PWM pin 11<br>int BluePin = 9; //Blue: PWM pin 9<br>void setup()<br>{<br>  Serial.begin(9600);<br>  //initial values (no significance)<br>  int red = 255;<br>  int blue = 255;<br>  int green = 255;<br>}</pre><pre>void loop()<br>{<br>  //protocol expects data in format of 4 bytes<br>  //(xff) as a marker to ensure proper synchronization always<br>  //followed by red, green, blue bytes<br>  if (Serial.available()&gt;=4) {<br>    if(Serial.read() == 0xff){<br>      red = Serial.read();<br>      green= Serial.read();<br>      blue = Serial.read();<br>    }<br>  }<br>  //finally control led brightness through pulse-width modulation<br>  analogWrite (RedPin, red);<br>  analogWrite (GreenPin, green);<br>  analogWrite (BluePin, blue);<br>  delay(10); //just to be safe<br>}</pre><p>Also, note that different led strips might have different pin ordering, so connect accordingly.</p><p>I would also like to mention that in the video, a scrolling text can be seen while the Processing code was running. This was originally there for me to debug my code. However, <strong>I removed that portion of the code</strong> in my final publish to make things slightly faster.</p><p>Finally, the comments to this post are filled with great questions, and great answers contributed by the awesome people of the DIY community. Also, many kind souls have contributed awesome snippets of code to add functionality such as multiple display and so on. Enjoy!</p><p><em>Originally published at </em><a href="http://siliconrepublic.blogspot.com/2011/02/arduino-based-pc-ambient-lighting.html"><em>siliconrepublic.blogspot.com</em></a><em> on February 8, 2011.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bb370b0b64f1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Arduino based Human Interface Device]]></title>
            <link>https://medium.com/@rjrshr/arduino-based-human-interface-device-50d32cebf816?source=rss-6804aa7112fd------2</link>
            <guid isPermaLink="false">https://medium.com/p/50d32cebf816</guid>
            <category><![CDATA[arduino]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Rajarshi Roy]]></dc:creator>
            <pubDate>Sun, 25 Dec 2016 03:06:00 GMT</pubDate>
            <atom:updated>2016-12-25T18:53:12.235Z</atom:updated>
            <content:encoded><![CDATA[<h4>Part 2</h4><p><em>Originally published at </em><a href="http://siliconrepublic.blogspot.com/2010/08/arduino-based-human-interface-device.html"><em>siliconrepublic.blogspot.com</em></a><em> on August 10, 2010.</em></p><p>Continuing from my last blog-post about creating Arduino based Human Interface devices, here is the video I promised:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FTv5sYkNn0zQ%3Ffeature%3Doembed&amp;url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DTv5sYkNn0zQ&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FTv5sYkNn0zQ%2Fhqdefault.jpg&amp;key=d04bfffea46d4aeda930ec88cc64b87c&amp;type=text%2Fhtml&amp;schema=youtube" width="640" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/05c79d11a712c5d49905e16f59a719a2/href">https://medium.com/media/05c79d11a712c5d49905e16f59a719a2/href</a></iframe><p>The <strong>PS2dev library</strong> (<a href="http://www.arduino.cc/playground/ComponentLib/Ps2mouse">http://www.arduino.cc/playground/ComponentLib/Ps2mouse</a>) lets the Arduino emulate a PS/2 device and I used a PS/2 to USB converter off the shelf for 3 bucks since my laptop does not have a PS/2 port. To use the PS2dev library, drag and drop the files ps2dev.h and ps2dev.cpp into your Arduino IDE before you upload it. They should appear as tabs with the corresponding names. Also, you have to go to the ps2dev.h tab and comment out <strong><em>#include “WConstants.h</em></strong> and add a line <strong><em>#include &lt;Wprogram.h&gt;</em></strong> until the start of the header file appears like:</p><pre>#ifndef ps2dev_h<br>#define ps2dev_h<br>//#include “WConstants.h”<br>#include &lt;Wprogram.h&gt;</pre><h4>Code:</h4><p>Now comes the code :) It is extremely shabby since I probably have unnecessary headers and variables lying around. And also I did not organize the code into any objects or classes whatsoever. However, I am planning to write a nice keyboard and mouse class using the PS2dev library so that future Arduino HIDers can effortlessly implement absolute/relative mouse movements, key-presses without referring to PS/2 scan codes and have a much much cleaner code :D</p><pre>#include &quot;ps2dev.h&quot; // to emulate a PS/2 device<br>#include &lt;Wire.h&gt; // to communicate over the I2C port<br>#include &lt;string.h&gt;<br>#include &lt;math.h&gt;<br>#undef int<br>#include &lt;stdio.h&gt;</pre><pre>uint8_t outbuf[6]; // array to store arduino input<br>int cnt = 0;<br>int ledPin = 13;</pre><pre>PS2dev keyboard(3,2); // PS2dev object (2:data, 3:clock)<br>int enabled =0; // pseudo variable for state of &quot;keyboard&quot;</pre><pre>int joy_x_axis; //byte 1<br>int joy_y_axis; //byte 2<br>int accel_x_axis; //byte 3<br>int accel_y_axis; //byte 4<br>int accel_z_axis; //byte 5<br>int z_button = 0;<br>int c_button = 0;<br>int roll = 0;<br>int pitch = 0;</pre><pre>void ack() {<br>  //acknowledge commands<br>  while(keyboard.write(0xFA));<br>}</pre><pre>int keyboardcommand(int command) {<br>  unsigned char val;<br>  switch (command) {<br>    case 0xFF: //reset<br>      ack();<br>      //the while loop lets us wait for the host to be ready<br>      while(keyboard.write(0xAA)!=0);<br>      break;<br>    case 0xFE: //resend<br>      ack();<br>      break;<br>    case 0xF6: //set defaults<br>      //enter stream mode<br>      ack();<br>      break;<br>    case 0xF5: //disable data reporting<br>      //FM<br>      enabled = 0;<br>      ack();<br>      break;<br>    case 0xF4: //enable data reporting<br>      //FM<br>      enabled = 1;<br>      ack();<br>      break;<br>    case 0xF3: //set typematic rate<br>      ack();<br>      keyboard.read(&amp;val); //do nothing with the rate<br>      ack();<br>      break;<br>    case 0xF2: //get device id<br>      ack();<br>      keyboard.write(0xAB);<br>      keyboard.write(0x83);<br>      break;<br>    case 0xF0: //set scan code set<br>      ack();<br>      keyboard.read(&amp;val); //do nothing with the rate<br>      ack();<br>      break;<br>    case 0xEE: //echo<br>      //ack();<br>      keyboard.write(0xEE);<br>      break;<br>    case 0xED: //set/reset LEDs<br>      ack();<br>      keyboard.read(&amp;val); //do nothing with the rate<br>      ack();<br>      break;<br>  }<br>}</pre><pre>void setup() {<br>  Wire.begin (); // join i2c bus with address 0x52<br>  nunchuck_init (); // send the initilization handshake<br>  delay(2000); //initialization time just in case<br>  // send the keyboard start up<br>  while(keyboard.write(0xAA)!=0);<br>}</pre><pre>void nunchuck_init ()<br>{<br>  Wire.beginTransmission (0x52);// transmit to device 0x52<br>  Wire.send (0x40);  // sends memory address<br>  Wire.send (0x00);  // sends sent a zero.<br>  Wire.endTransmission (); // stop transmitting<br>}</pre><pre>void send_zero ()<br>{<br>  Wire.beginTransmission (0x52);// transmit to device 0x52<br>  Wire.send (0x00);  // sends one byte<br>  Wire.endTransmission (); // stop transmitting<br>}</pre><pre>void loop() {<br>  Wire.requestFrom (0x52, 6); // request data from nunchuck<br>  while (Wire.available ())<br>  {<br>    outbuf[cnt] = nunchuk_decode_byte (Wire.receive ()); <br>    // receive byte as an integer<br>    digitalWrite (ledPin, HIGH); // sets the LED on<br>    cnt++;<br>  }</pre><pre>// If we recieved the 6 bytes, then go process them<br>  if (cnt &gt;= 5)<br>  {<br>    process ();<br>  }</pre><pre>unsigned char c;<br>  //if host device wants to send a command:<br>  if( (digitalRead(3)==LOW) || (digitalRead(2) == LOW)) {<br>    while(keyboard.read(&amp;c)) ;<br>    keyboardcommand(c);<br>  }<br>  else{ //send keypresses accordingly using scancodes<br>    if(joy_y_axis &gt; 198){keyboard.write(0x1D);}<br>    else{ keyboard.write(0xF0); keyboard.write(0x1D);}</pre><pre>if(joy_y_axis &lt; 68){keyboard.write(0x1B);}<br>    else{ keyboard.write(0xF0); keyboard.write(0x1B);}</pre><pre>if(joy_x_axis &lt; 58){keyboard.write(0x1C);}<br>    else{ keyboard.write(0xF0); keyboard.write(0x1C);}</pre><pre>if(joy_x_axis &gt; 190){keyboard.write(0x23);}<br>    else{ keyboard.write(0xF0); keyboard.write(0x23);}</pre><pre>if(pitch &lt; 65){keyboard.write(0x43);}<br>    else{ keyboard.write(0xF0); keyboard.write(0x43);}</pre><pre>if(pitch &gt; 115){keyboard.write(0x42);}<br>    else{ keyboard.write(0xF0); keyboard.write(0x42);}</pre><pre>if(roll &gt; 125 ){keyboard.write(0x3B);}<br>    else{ keyboard.write(0xF0); keyboard.write(0x3B);}</pre><pre>if(roll &lt; 55){keyboard.write(0x4B);}<br>    else{ keyboard.write(0xF0); keyboard.write(0x4B);}</pre><pre>if(!z_button){keyboard.write(0x29);}<br>    else{ keyboard.write(0xF0); keyboard.write(0x29);}</pre><pre>if(!c_button){keyboard.write(0x12);}<br>    else{ keyboard.write(0xF0); keyboard.write(0x12);}<br>  }</pre><pre>cnt = 0;<br>  send_zero (); // send the request for next bytes<br>  delay (10);<br>}</pre><pre>void process (){<br>  joy_x_axis = outbuf[0]; //byte 1<br>  joy_y_axis = outbuf[1]; //byte 2<br>  accel_x_axis = outbuf[2] * 2 * 2; //byte 3<br>  accel_y_axis = outbuf[3] * 2 * 2; //byte 4<br>  accel_z_axis = outbuf[4] * 2 * 2; //byte 5</pre><pre>z_button = 0;<br>  c_button = 0;</pre><pre>roll = 0;<br>  pitch = 0;<br>  // byte outbuf[5] contains bits for z and c buttons<br>  // it also contains the least significant bits for the accelerometer data<br>  // so we have to check each bit of byte outbuf[5]<br>  if ((outbuf[5] &gt;&gt; 0) &amp; 1) //&#39;&amp;1&#39; to see only LSB after left shifts<br>  {<br>    z_button = 1; //bit 0<br>  }<br>  if ((outbuf[5] &gt;&gt; 1) &amp; 1)<br>  {<br>    c_button = 1; //bit 1<br>  }</pre><pre>if ((outbuf[5] &gt;&gt; 2) &amp; 1)<br>  {<br>    accel_x_axis += 1;<br>  }<br>  if ((outbuf[5] &gt;&gt; 3) &amp; 1)<br>  {<br>    accel_x_axis += 2;<br>  }</pre><pre>if ((outbuf[5] &gt;&gt; 4) &amp; 1)<br>  {<br>    accel_y_axis += 1;<br>  }<br>  if ((outbuf[5] &gt;&gt; 5) &amp; 1)<br>  {<br>    accel_y_axis += 2;<br>  }</pre><pre>if ((outbuf[5] &gt;&gt; 6) &amp; 1)<br>  {<br>    accel_z_axis += 1;<br>  }<br>  if ((outbuf[5] &gt;&gt; 7) &amp; 1)<br>  {<br>    accel_z_axis += 2;<br>  }</pre><pre>//out here the values 499, 518 and 216.0 might differ<br>  //due to the slight differences nunchucks<br>  roll = (atan2( (accel_z_axis-499), (accel_x_axis-515) )/3.14159*180);<br>  pitch = (acos( (accel_y_axis-518)/216.0 )/3.14159*180);<br>}</pre><pre>// Encode data to format that most wiimote drivers except<br>// only needed if you use one of the regular wiimote drivers<br>char nunchuk_decode_byte (char x)<br>{<br>  x = (x ^ 0x17) + 0x17;<br>  return x;<br>}</pre><h4>Schematic:</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/0*9I4UkFAt22eWePCG.jpg" /></figure><p>Enjoy!</p><p><em>Originally published at </em><a href="http://siliconrepublic.blogspot.com/2010/08/arduino-based-human-interface-device.html"><em>siliconrepublic.blogspot.com</em></a><em> on August 10, 2010.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=50d32cebf816" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Arduino based Human Interface Device]]></title>
            <link>https://medium.com/@rjrshr/arduino-based-human-interface-device-701e85a570d4?source=rss-6804aa7112fd------2</link>
            <guid isPermaLink="false">https://medium.com/p/701e85a570d4</guid>
            <category><![CDATA[arduino]]></category>
            <category><![CDATA[iot]]></category>
            <dc:creator><![CDATA[Rajarshi Roy]]></dc:creator>
            <pubDate>Sun, 25 Dec 2016 00:04:00 GMT</pubDate>
            <atom:updated>2016-12-25T18:54:41.212Z</atom:updated>
            <content:encoded><![CDATA[<h4>Part 1</h4><p><em>Originally published at </em><a href="http://siliconrepublic.blogspot.com/"><em>siliconrepublic.blogspot.com</em></a><em> on August 5, 2010.</em></p><p>This summer I have been tinkering with my Arduino micro-controller and recently bought Wii Nunchuck in a quest to create a Wii Nunchuck based HID for playing games. Since the beginning of summer I have tried many different methods for doing so and here are some advantages and disadvantages of each:</p><p><strong>AAC keys</strong> (<a href="http://www.aacinstitute.org/downloads/aackeys/AACKeys.html">http://www.aacinstitute.org/downloads/aackeys/AACKeys.html</a>):</p><p>This software is excellent and hassle-free for sending keypresses to your computer. You just have to use a command from your Arduino sketch such as Serial.print(“\033left.”); to send a keypress (in this case left arrow button). However, the disadvantage of using AAC keys is that keys are pressed and released. There is no way to press and hold down any key other than Shift, Ctrl and Alt. This isn’t good for playing games where you usually need more than three keys.</p><p><strong>Gobetwino</strong> (<a href="http://www.mikmo.dk/gobetwino.html">http://www.mikmo.dk/gobetwino.html</a>):</p><p>Another great software that allows you to do a bunch of useful stuff such as opening/closing programs, sending emails, and sending keypresses to programs from your Arduino. It is also well documented. However, I had problems opening some games and holding down keys.</p><p>This method really worked well as I could hold down and release keys whenever I wanted to and worked with most games. I simply added this class to my Processing sketch in three lines:</p><pre>import java.awt.AWTException;<br>import java.awt.event.InputEvent;</pre><p>Created an object of the class: Robot ricky<br>And generated key-downs, key-ups and mouse mouse movements:</p><pre>ricky.keyPress(KeyEvent.VK_I);<br>ricky.keyRelease(KeyEvent.VK_I);<br>ricky.mouseMove(x,y);</pre><p>And my Arduino program sent the data from the Wii Nunchuck to the Processing sketch.</p><p>However, this method did not work with some older games on compatibility mode, and definitely would need some tweaking to make it work in different computers (like installing Arduino driver and Processing).</p><p>Thus, my final attempt was to make a truly plug-n-play Arduino based “adapter” that would allow me to hook up my Wii Nunchuck and play games with it on any computer, on any games, in any OS. So I used the <strong>PS2dev library</strong> from the Arduino playground (<a href="http://www.arduino.cc/playground/ComponentLib/Ps2mouse">http://www.arduino.cc/playground/ComponentLib/Ps2mouse</a>)</p><p>which allows you to let the Arduino emulate a PS/2 device. I wrote a code for emulating a PS/2 keyboard and it works great :D. Now you can play Paratroopers (image below) on your old IBM pc using the Wii Nunchuck over the PS/2 protocol or hook it up to your Altera DE2 for whatever you can think of ;)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/200/0*YvEd6pW44XjdOyH5.jpg" /></figure><p>As for me, I connected it up to a USB to PS/2 converter to play games. The pins 3 and 4 of the PS/2 port powers the Arduino :) Here are some pictures of my build:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/320/0*dbxTmTYP_QWmeklo.JPG" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/320/0*qeA9uOCTmZyf5aag.JPG" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/320/0*h7V6IPl0iPP4IH3f.JPG" /></figure><p>The joystick generates W,A,S,D based on position. The accelerometer roll and pitch generates I,J,K,L. The z-button generates Spacebar and the c-button generates Shift. Good enough for most games :) Mouse positions can be controlled using numpad keys in most OSs so thats not a problem either :)</p><p>I will be posting my code and a video for you to enjoy in my next blog-post. I hope this article is useful for all Arduino fans interested in making their own custom HIDs over the PS/2 or USB ports.</p><p><em>Originally published at </em><a href="http://siliconrepublic.blogspot.com/"><em>siliconrepublic.blogspot.com</em></a><em> on August 5, 2010.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=701e85a570d4" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>