Dark Matters
  • About Me
  • Publications
  • Educational Resources
  • Blog
  • Other Interests

IBM Ponder This for February 2013

2/28/2013

0 Comments

 
Tonight, I decided to work on this month's Ponder This problem. It reads as follows:
James Tanton tweeted (https://twitter.com/jamestanton/status/293127359291330561) that "16 and 9 are each square numbers, and putting them together, 169, gives another square" and he then asked for other examples.

Our challenge this month is to find integers x, y, and z such that concatenating x^2 and y^2 gives z^2, and that z has at least four consecutive nines.

Update 2/6: the challenge stating that x,y and z should be non-zero.
The brute-force solution to this problem is pretty straightforward. I used Mathematica, but any programming language will work. In this program below, I generate lists of x^2 and y^2 values. I then convert those numbers to strings, concatenate the strings, convert those strings back into a number and check if the square root (z) is an integer. The (x,y,z) values that meet this condition are stored in the checkres list. To check is z contains more than four 9's, I convert z back into a string and look for any substring within z that contains four of more 9's. The (x,y,z) values that fit this criteria are stored in the results list.

The major hurdle in this problem is figuring out where in x-y parameter space to search. For x<1,000 and y<1,000, the are no more than two consecutive 9's and computing time starts to become an issue in Mathematica. For 1,000<x<10,000 and 1,000<y<10,000, there are three z values with three consecutive 9's. For a language such as Python or C++, the computing time would be significantly faster. I chose Mathematica for the ease of moving between data types.

I have not had much luck reducing the parameter space for viable solutions. Below is the brute force Mathematica code to show solutions with two or more consecutive 9's. The x or y value is at least 5 digits. I found some reliable ways of general solutions with three consecutive 9's, but the four 9 solutions were elusive for longer than I care to admit. 
Picture
After looking at it for a while longer, I found that numbers of the form x=49999... and y=99999.... will produce an increaseing string of 9's in z when their squares are concatenated. Here are the solutions for four through eleven 9's. I'm sure there are solutions I am missing, but I believe this solves the problem as stated. 
Picture
Update: IBM has since posted an algebraic solution to this problem. They have not yet reviewed my solution since I accidentally sent them the wrong file at first.
0 Comments

Arduino Report #13: Project 19--Tune Player

2/16/2013

3 Comments

 
Additional Parts:
  1. 100 nF non-polarized capacitor x1
  2. 100 uF, 25v electrolytic capacitor x1
  3. 10k Ohm resistor x5
  4. 4.7k Ohm resistor x3
  5. 1M Ohm resistor x1
  6. 10k Ohm linear potentiometer x1
  7. TDA7052 1W audio amplifies x1
  8. Small 8 Ohm loudspeaker x1

Time to Complete: 30 minutes
Picture
This project is awesome. With just a handful of parts, I have assembled a crappy synthesizer the can play any tune that is programmed into it. In the video below, the Arduino plays the default song "Jingle Bells". The potentiometer is used as a volume knob. 

The program for the project is interesting in that each note must be separately constructed from the appropriate sine wave, and the duration of each note must be adjusted so they are all roughly equal. The author has taken the time to create two octaves worth of notes. The song below is played in the higher octave. After I took the video, I played it in the lower octave, which sounded better. Since the notes are already defined, it's possible to play any song by simply writing the appropriate notes and spaces to account for the duration of the notes and silences between them. It would also be simple to add the accidentals to the array of available notes. By default, the only available notes are two octaves of ABCDEFG. Perhaps I will take the time to add the accidentals and program a new tune. I also think I made need to make some adjustments to tune the tune player. "Jingle Bells" sounds pretty bad.

3 Comments

Arduino Report #12: Project 21--VU Meter

2/15/2013

0 Comments

 
Additional Parts:
  1. 220 Ohm Resistor x 10
  2. 10k Ohm Resistor x3
  3. 100k Ohm Resistor x1
  4. BC548 Transistor x1
  5. Push-to-make Switch x1
  6. Electret Microphone x1
  7. 10-Segment LED Bar Graph x1
  8. 100 nF Capacitor x1

Time to Complete: 30 minutes
Picture
The VU Meter records the volume of sound picked up by the electret microphone and displays the intensity in the LED bar graph. There are two modes. The first displays the intensity in real time, and the second mode records only the highest intensity picked up by the microphone. The push-to-make switch is used to toggle between the modes. 

The most interesting part of the circuity in this project is in the wiring of the microphone and the transistor used to amplify the signal from the mic. The transistor is wired in a collector-feedback bias arrangement. In order to avoid a discreet switching of the transistor on an off, part of the voltage at the collector is used to bias the transistor. This lets the transistor amplify the signal from the microphone in a linear fashion. Clever. There are some subtleties in the program to ensure that the transistor bias does not permanently  illuminate the button bars of the LED. Other than that, the program is pretty straight-forward.



My eldest son helped me out with this video this time by clapping into the microphone as I filmed.

0 Comments

Arduino Report #11: Project 10--Keypad Security Code

2/9/2013

0 Comments

 
Additional Parts:
  1. Red LED x1
  2. Green LED x1
  3. 220 Ohm Resistor x2
  4. 4x3 Keypad x1
  5. 8-pin header strip

Time to Complete: 30 Minutes
Picture
The project was fun because of the possible applications. The idea is very simple. Once a preset combination is pressed into the keypad, the red LED will turn off and the green LED will turn on. Pressing the asterisk or the pound symbol turns off the green LED and on the red LED. These characters also reset the keypad when entering a code. 

The most difficult part of this project was determining what each pin on the keypad does. The keypad I purchased was not configured the same way at the one used in the book. With my handy-dandy multimeter, I was able to figure out the mapping for each button and rewired my circuit accordingly. 

This project also introduced the concept of importing libraries into the code. In this case, it was keypad library to account for the fact that in practice, pressing a button is very rarely a binary action. The connections are not perfect so there are actually multiple pressings happening very quickly. The library tells the Arduino how to handle this situation.

It is not very hard to imagine how to extend this project to be able to externally set a new code or create a whole menu of options. A video is, of course, below. 

0 Comments

Arduino Report #10: Project 14--Multicolor Light Display

2/9/2013

0 Comments

 
Additional Parts:
  1. Multicolor LED x1
  2. Rotary Encoder
  3. Push-to-make Switch
  4. 100 Ohm Resistor x3
  5. 100k Ohm Resistor x3

Time to Complete: 15 min
Picture
This project is a simple extension of the Model Traffic Signal Using a Rotary Encoder project. Instead of a series of LEDs where the timing between the flashes changes, the rotary encoder is used to change the color coming from the multicolor LED. Again, I did not have a rotary encoder with a built-in switch, so I had to wire one up separately. The switch turns the LED on and off. Holding the switch makes it blink. Rotating the encoder switches among the 40-some colors in the program.

My shoddy soldering job from the previous project came back to haunt me. The connection on the rotary encoder was bad so it did not always work. Shortly after taking the video, one of the wires fell off. This is what I get for soldering in the dark, late at night with the kids in bed. In the video, you can see that I have to struggle with the encoder to get the LED to change colors. I show the full range of colors available, but when the connection is better, the colors change on each click of the encoder.

0 Comments

Arduino Report #9: Project 11--Model Traffic Signal Using a Rotary Encoder

2/7/2013

3 Comments

 
Additional Parts:
  1. Green LED x1
  2. Red LED x1
  3. Orange LED x1
  4. 220 Ohm x3 
  5. 100k Ohm x3
  6. Push-to-make switch x1
  7. Rotary Encoder x1

Time to Complete: 45 min
Picture
This project is very similar to the Model Traffic Signal I wrote about before. The difference is that a rotary encoder is introduced to control the frequency at which the lights change. A rotary encoder is a knob that with two output pins that can be used to determine if it was turned clockwise or counter-clockwise. Unlike a potentiometer, a rotary encoder can be rotated indefinitely. They are commonly found employed as stereo volume knobs. Many rotary encoders also incorporate a push-to-make switch built into the knob. Unfortunately, I did not read closely enough when I was ordering new parts so my rotary encoders are buttonless. However, I did have a push-to-make switch in my box-o-parts, and with a little modification, I was able to complete the project with total functionality. 

This project was not without its small hangups. I quickly broke the output pins on the rotary encoder trying to put it into the breadboard. As a result, I ended up soldering wires onto the nubs where the contacts were. This ended up being advantageous in the end as the rotary encorder can now sit away from the tangled mess of the breadboard. I was able to quickly determine, from the data sheet from the rotary encoder and from my previous experience with the push-to-make switch, how to adjust the circuit for the buttonless rotary encoder. The circuitry is above and the video is below. Pushing the button turn on all the lights simultaneously. A clockwise rotation of the encoder slows down the light change rate while a counter-clockwise turn speeds it up. Again, the traffic light pattern is in the UK style.


Next project will probably be the Keypad Security Code or one of the more advanced LED displays depending on when the Mouser shipment arrives. I'm still waiting on a few transistors. 

3 Comments

Arduino Report #8:  More Parts

2/7/2013

0 Comments

 
I finally ran out of projects that could be done with the parts I had on hand so I placed an ordern with Digi-Key and another with Mouser. The Digi-Key order has arrived and contains a 4x3 keypad, some rotary encoder, thermistors with available data sheets and the matching resistors, some transistors, and a pair of relays. Once the Mouser order comes in, I should be able to do all but the most costly projects. I think I'm up to about $100 in parts. The last two orders were about $30 each with the most expensive part being the keypad at about $14. I also purchased a soldering iron last weekend that is included in the total. 
Picture
Since I bought a new thermistor and resistor pair, I decided to quickly redo the USB Temperature Logger project to see how far off I was before. This time, I decided to plug the components directly into the Arduino as seen on the left. The temperature in my living room was 71.5 F based on the digital clocked sitting near the radiator. My desk, where the Arduino is located is a similar distance from the radiator as the digital clock.  As you can see below, the values are similar to last time. I guess the thermistor values I used last time were accurate enough.

Picture
0 Comments

Arduino Report #7: Project 13--USB Temperature Logger

2/2/2013

0 Comments

 
Additional Parts:
  1. Thermistor, 38k Ohm, Beta=3970
  2. 44k Ohm Resistor

Time to Complete:
30 minutes
Picture
As you can see from the title, I am now skipping around freely through the book. I am quickly running out of projects that I can do with my current supply of random electronics parts. It's about time to hit up Digi-Key or Mouser. 

This is the first project I have done that has a practical application. The purpose of this project is to make a data logging thermometer. That means, I will be able to detach the Arduino and leave it on 9V battery power while it takes temperature at specified timing intervals. Later, I can reattach it via USB and read off the temperatures.  As you can see from the picture above, the electronics is very simple.


The temperature senor (thermistor) is merely a resistor that is very sensitive to small fluctuations in temperature. The thermistor is characterized by its resistance at a certain temperature and a value beta that represents the exponential decay constant in converting from the resistance of the thermistor to the ambient temperature. The thermistor should be paired with a resistor of the same resistance. Note that mine are a little mismatched. This and the fact that the thermistor I had did not have a data sheet (Who knows if the value I looked up was correct?) means that I the values from the logger will probably be off a little bit. 

The program for this project is the most complicated one I have seen from this book so far. The Arduino is programmed to accept commands through the serial monitor. The units of the logger can be set to either Celsius or Fahrenheit. The interval between data points can be changed, and the data logging can be stopped, started, or read out. The measured resistance of the thermistor is converted to the appropriate temperature and stored in the local memory of the Arduino. This memory is kept even if the Arduino is unpowered. Therefore, it must be manually set between data sets. Instead of a video, I have included a graph of the temperature of my living room below. The thermometer I have in the living room said 73.5 F at the time the reading. The Arduino logger did ok. An accurate beta value and a well-matched resistor would probably fix the accuracy problem. It was definitely not 76 F in my living room. 

Picture
0 Comments

    Archives

    July 2015
    February 2014
    November 2013
    October 2013
    September 2013
    July 2013
    June 2013
    May 2013
    April 2013
    March 2013
    February 2013
    January 2013

    Categories

    All
    Arduino
    Chess
    Lightsaber
    Math
    Probability
    Projects
    Python
    Raspberry Pi
    Robotics
    Statistics

    The Great Arduino Project

    RSS Feed

Powered by Create your own unique website with customizable templates.