arduino

Update to Arduino Random Library!!!

Recently I have been working on the new api for the Arduino Random library. The library now has methods that return different integer sizes from byte to long. I’m not sure if I’ll add long long though as the delay would be too great. This is because the library will block the MCU until it has gathered all of the entropy. If the source of randomness going into the Arduino’s ADC is not very random the library can take a long time to generate the bits. This is especially true of the von neumann debiasing code since it truncates long stretches of ones or zeros.

The library is based on code by Rob Seward albeit heavily modified. Most of the debiasing code remains the same as well as the calibration code. The new code is now up on Github at https://github.com/infomaniac50/Random/. Feel free to fork away and make changes as you see fit. If you use the code please include links back to this blog. I’m sure Rob would like to see some attribution to him as well.

If anybody has any questions feel free to leave a comment, but please, only if you are human.

Posted by admin in Electronics, Programming, 0 comments

Xbox 360 Remote Control with an Arduino

I recently made a neat little gadget with my Arduino Mega that controls my Xbox 360. It uses the remote control codes from the lirc project. I used an old keypad and an infrared led I found at a hamfest. Its works really good for controlling Hulu and Netflix. I used to have to turn the controller on and wait for it to connect when all I wanted to do is pause the video. With this I just turn on the Arduino and press the pause button and the Xbox pauses the video. It is so much easier now to control the xbox. What I would really like to do is turn it into a permanent device with maybe a touch screen and learning capabilities. Then it would be just like one of the logitech 100 dollar remotes. As of right now it runs on my breadboard. The infrared led is controlled with a library from the experimental branch of Ken Shirriff’s IR library. My version of the library also includes the ability to control Panasonic devices. I previously used it to control my 50″ Panasonic. The library uses the pwm output of timer 2 on the arduino, which on the mega is pin 9. Ken’s blog says pin 3 but that is for the Arduino Uno. The circuit includes a transistor because it is drawing more current than a pwm pin can supply. I didn’t have any low value resistors, so I hooked four 220 ohm resistors in parallel. I also modified the Keypad library from the arduino.cc playground to work with my old non-matrix keypad. Both modified versions of the libraries are available on Github here KeypadSimple and here IRremote.

Here are some pictures of it wired up on the breadboard. Click on any of them to get a close up.

 

Posted by admin in Electronics, Programming, 8 comments

Arduino Hardware Random Number Generator

I have been dabbling in cryptography for a while now and recently I got into random number generators. I found out that crypto libraries use random number generators all the time. You would have to be able to keep the output of the library unpredictable to ensure security. They do that mostly with pseudo random number generators. In other words they use an algorithm to generate the random numbers. These algorithms take a seed value to start the sequence and then only go for so long before the sequence repeats itself. So by using a true random number generator you can ensure that the output of the crypto library is kept secure.

I wanted a random number generator for my own use and I came upon a page on Rob Seward’s blog for a random number generator using the arduino as the hardware interface. The board works by taking the noise that you get from running the pn junction in reverse breakdown mode. Then amplifying it through two stages and sampling it with the Arduino’s ADC. I don’t have an oscilloscope so I don’t know what the noise distribution looks like. However, I have collected the random output on a computer and ran it through a basic entropy test. The output of ent.exe from http://www.fourmilab.ch/random/looks pretty good. This was done on a 5MB file so I imagine if I get more samples the chi squared distribution would increase as well.

C:\Apps>ent -b random.dat
Entropy = 1.000000 bits per bit.

Optimum compression would reduce the size
of this 41943040 bit file by 0 percent.

Chi square distribution for 41943040 samples is 0.00, and randomly
would exceed this value 95.89 percent of the times.

Arithmetic mean value of data bits is 0.5000 (0.5 = random).
Monte Carlo value for Pi is 3.141912514 (error 0.01 percent).
Serial correlation coefficient is 0.000081 (totally uncorrelated = 0.0).

Here are some pictures of the peripheral board I put the circuit on.

Here are some pictures of it connected to the Arduino.

Here is the code I used for the Arduino. I made quite a few modifications to it, most notably I transformed it into libraries so you can use it in your own code. The code should be up on GitHub shortly, but if not it means I am still tweaking it.

True Random Logger

Posted by admin in Electronics, Programming, 4 comments