29 August 2013

Adventures in Programming

A couple weeks ago, I learned how to program in Python with the Raspberry Pi, which was a lot of fun. Python is a great language to get started with. I played around with writing programs that do different mathematical functions (that's a mouthful to pronounce!): counting, doubling, and soon, a function that gives a Fibonacci number. A Fibonacci number is a number in this set: 0, 1, 1, 2, 3, 5, 8, 13... You add the 2 numbers before the current one to get the next number. And, if you make successive ratios with the Fibonacci numbers, they tend to the golden ratio: 0/1 = 0, 1/1 = 1, 1/2 = .5, 2/3 = 0.33 repeated, 3/5 = .6, 5/8 = .625, etc. The true golden ratio is 0.618... Python also does not need semicolons at the end of every line, like Arduino or C. I am also working on the algorithm for a function that spits out prime numbers, which I thought would be easier than it actually is!

24 July 2013

Random Number Generator Sensor Network (RNGSN)

Today I had an idea for a random number generator. I call it the RNGSN, for short. It is a bunch of  sensors connected to a microcontroller, which takes the values of the sensors (6 in all, in my design) and divides them by the number of sensors to get the average value, which theoretically is a true random number. You would put all of the sensors in a different spot. If you want the sensors to be a fairly long distance apart, say, a hundred feet, you could have the sensors connected to microcontrollers with radios connected to them, which then send the value of the sensor over radio to the main controller, which then averages them. I'm still brainstorming the system, but I think I'm definitely going to use a light sensor and a pressure sensor.


19 July 2013

How To #11: Arduino #4

In this Arduino How To, I'm going to teach you the basics of serial communication. The serial communication commands for the Arduino are very easy to use and are useful for debugging.
The code for the serial hello world is:
void setup()
{
      Serial.begin(9600);
}

void loop()
{
      Serial.println("Hello World");
      delay(500);
}
In the setup, you initialize the serial communication. The 9600 is the bits per second, or bps. You can make this go twice as fast, but for most purposes, you can keep it at 9600. In the loop, the code prints Hello World to the serial monitor every 500 milliseconds. The println command prints a value and adds a carriage return and newline (it prints Hello World, "presses enter", and repeats). Instead of just sending text, you can send anything from values of sensors to Internet data (with some extra hardware).
Here's the code for the next example:
const int potPin = A0;
int potVal = 0;

void setup()
{
      pinMode(potPin, INPUT);
      Serial.begin(9600);
}

void loop()
{
      potVal = analogRead(potPin);
      Serial.println(potVal);
}
In the very first lines, some variables are made for the pin that the potentiometer is connected to, and the value of that pin. In the setup, the potPin is declared an input, and serial communication is initialized. In the loop, potVal is given the value of the analog read of potPin, and the Arduino prints out potVal.

08 July 2013

Rep Rap First Print

Last night I fixed my Rep Rap! I only solved one problem with it, and that was a mechanical/software problem. The other problem is the extruder. It leaks out a little bit of plastic, but it's enough to cause a problem. I think my dad and I might need to buy a new extruder, or we'll take it apart, fix it, and put it back on. There might be a string here or there, but overall, it prints nicely. Once it's completely fixed, my goal is to print a Klein bottle.
2 hours and one glass of horchata later…


02 July 2013

IR Flasher

Last week, I started a new project for my dad's work that flashes an IR LED. It flashes on and off every 240 milliseconds. You can see the LED flash by using a cheap camera or night vision goggles. The entire circuit is based around a 555 timer in astable mode. I haven't soldered it together yet, but I will soon. The first version will have one IR LED, but once I see that it works, I'm going to add one or two more. The box that it will go in is really small; it's about the size of 1 1/2 9V batteries. Once I've gotten the whole thing perfected, I'm going to build a couple and have a night vision war in my cul de sac.



29 May 2013

Cool Science #1: Time Travel Physics

I'm starting a new section on my blog called Cool Science, where I write about science that I see that looks really cool (hence the name Cool Science).
The topic of this Cool Science is the physics of time travel, one of my favorite topics. Time travel is about going through time. If time travel is possible, then you could go back in time and forward in time. The first form of time travel I'll talk about is going forward in time.
Going to the future is really easy: go into orbit, stay in orbit for a year, and come back down. You are now a fraction of a second into the future. Okay, it's not really easy, but it is compared to going back in time. If you wanted to go, say, a thousand years into the future, you need to go a lot faster. If you want to go a substantial amount of years into the future, then you need to go close to the speed of light (about 99.9% of the speed of light). Now, if you stayed in orbit for a year, but kept your engines on for that entire time, you would come back to see that you have gone 223 years into the future. Stay in orbit for about 5 years with your near light speed engines on, you would go about a thousand years into the future.
Going back in time is much harder. If you want to go to last year, you need to travel faster than light. The engines in your rocket need to have FTL (faster than light) capabilities. Right now, there is no known way to travel faster than light, but there are theories. Assume that space is 2D and is curved. If two black holes go to the same spot on their side of space, they will create an Einstein - Rosen bridge, more famously called a wormhole. A wormhole links two regions of space together, and two times together. Instead of going the long way around space, go through a wormhole. Light travels the long way, you go through the wormhole, and you have traveled faster than light.
The only problem with wormholes is that they are extremely unstable. They decay so fast that a light ray cannot propagate through one. You would need a machine that could hold open a black hole, much like a wedge holds open a door.
There are many theories about time travel, I just wanted to talk about popular methods of theoretically time travelling.
If you want to check out more stuff about time travel, look at How Stuff Works and A Brief History of Time.

19 April 2013

How To #10: Raspberry Pi

For the 10th How To in the history of this blog, I thought I would do a How To special: Raspberry Pi! In this post, I will teach you about Raspberry Pi, how to get started, and some other tidbits of information.

About Raspberry Pi
Raspberry Pi is a small board that has a computer on it. The computer on the Raspberry Pi is the same you would find in a Kindle. It runs on Linux and its "hard drive" is a 4 gigabyte or above SD card. It is powered by a normal cell phone charger or any other power supply that can give 5V and maybe 1A. You can program it to do certain things, like an Arduino or other microcontroller. You can program an Arduino from a Raspberry Pi, too.

How To Get Started
I won't be explaining every detail of the getting started process, but I will give some, like the parts and the SD card. First, you need to have: a Raspberry Pi, a power supply, a USB cable, a mouse, a keyboard, an SD card, a laptop, and a monitor. You need the laptop in order to format the SD card. If your laptop does not have an SD card reader, then you need to buy one that is compatible with your computer. Once you do that, go on to the Raspberry Pi website and download the Raspbian file or other system, and, if you want to, download the torrent file. Next, move the file to the SD card, wait a little bit, and the operating system is now on the SD card. Furthermore, put the SD card in the Raspberry Pi, connect all the equipment to the Raspberry Pi, and power it on. If it does not work, check to make sure that everything is plugged in correctly, that you downloaded the system correctly, and, if all that checks out okay, pinch the SD card between your thumb and the Raspberry Pi board. Once you have it pinched, power on the board. If it works, find a way to keep the SD card tight. I used this strategy, and it worked. Check out the troubleshooting page on the Raspberry Pi website for more methods.
A really useful book I used was Getting Started with Raspberry Pi by Matt Richardson. It goes over a lot of stuff that I didn't include here. Once you have everything going, do some awesome projects with the Raspberry Pi, and have fun!