Friday, 2 December 2016

Pet Feeder

Just a simple holiday project.

Check it out:


Tuesday, 15 November 2016

Python + Arduino Project


Virtual Object Controller

  Recently I've been trying to learn a bit of Python and decided to build a project for fun.
This project has a simple objective: To control a virtual object using a set of potentiometers.

  By Connecting a set of potentiometers to an Arduino, this gave me the ability to manipulate two variables. I decided to manipulate the x-axis and the y-axis of a virtual box in Python.

  The Arduino's circuit is simple. It has 2 potentiometers and 2 LEDS which will have different light intensities based on how much the potentiometer is being turned.

  Here goes my attempt at explaining how the code works. *takes a deep breath*

  Let's take a look at the Arduino's code:
  The parts with the //(comment) is the explanation

//Moving a virtual object using potentiometers

int ledx = 5;   //Variables for LED pins
int ledy = 6;

void setup() {
  // put your setup code here, to run once:
Serial.begin (9600);                                                      //Initialize serial communication
pinMode(ledx, OUTPUT);
pinMode(ledy, OUTPUT);

void loop() {
  // put your main code here, to run repeatedly:
  int potx = analogRead(A0);                                         //declaring some variables to hold the                  int poty = analogRead(A1);                                           potentiometer reading
  int xval = map(potx, 0, 1023, 0, 50);                           //Here I am mapping the x-axis potentiometer
  int yval = map(poty, 0, 1023, 51, 101);                         from 0-1023 to 0-50. Smaller numbers will 
  int xled = map(potx, 0, 1023, 0, 255);                           help me manage the programming easier.
  int yled = map(poty, 0, 1023, 0, 255);                           Y-axis potentiometer is mapped to 51-101
                                                                                         because they need separate values to 
//0-50 is the range of values for x axis                            differentiate x and y axis. I'm also mapping 
//51-100 is the range of values for y axis                        the pot values to 0-255 for PWM for LEDS

//Varying light intesities based on the degree of movement of the x and y axis. (based on the potentiometer)

analogWrite(ledx, xled);
analogWrite(ledy, yled);

//Sending the potentiometer values to Python
Serial.println(xval);                                                     //Sending the values one by one to Python in
delay(10);                                                                      the form of string.


Now let's take a look at the Python side of the program: (# are for comments)

import serial                                               #Importing the necessary libraries for the code to work
from visual import * 

arduinoSerialData = serial.Serial('com6', 9600)        #Setting up serial communication, take note of
                                                                                     com port and baud rate (same with Arduino)

virtualObject = box(color =, length = 3, width = 3, height = 3, pos = (0,0,0))

#Declaring an object to set up the shape. In my case, I'm using a box, the values in the brackets are
the parameters for the box. The 'pos' value is what we need to change dynamically, (x,y,z) axis. We don't have to bother with the Z axis in this case.

y = 0     #Declaring the variable used to change the Y-axis,  not sure why only y is needed, but the 
               code does not work without this.

while (1==1):        #Run everything in a loop
    rate(200)           #How fast it runs (tried 20, doesn't work too well)
    if (arduinoSerialData.inWaiting()>0):            #Check to see whether there's data
        value = arduinoSerialData.readline()          #Write the data in a variable called value
        data = int(value)                                           #Convert the string format data into an integer
        if (data < 51):                   #If the potentiometer reading is less than 51, the value received is
            x = data                          for the X-axis. Write the value into a variable called x.
        if (data > 50):                      #If the potentiometer reading is more than 51, the value received is
            y = data - 51                      for the Y-axis. Write the value into a variable called y. Minus the
                                                       value with 51 so that it starts from (0,0).

        virtualObject.pos = (-30 + x,-30 + y, 0)      #This is in charge of drawing the box itself. Notice 
                                                                              the variables in the position. This will enable                                                                                           updating of the x and y coordinates. I also start with
                                                                               (-30,-30) so that there's more space for the box to 
                                                                               move around.

Don't copy and paste the program from here. It might get messy. Instead, download it from my Google Drive folder.

Tuesday, 27 September 2016

We gave a talk at Taylor's International School!

It's a shame that we don't have a clip of our talk, but here's the slides we used.

  We basically talked about the competition and our experiences. Well, Jai and Ruhanesh talked about that, my part of the talk was more towards the internal factors, not so much physical, but more towards the mental aspects of our success.

Have a look.

Sunday, 28 August 2016

Project EOT

Hey guys, here's my latest project.

Introducing project EOT!

EOT, which stands for English Oral Test, consists of two robots which serve different functions.
One of them is a music player, while the other one is a magic robot. 

  So, my school recently had a oral test in which we have to give a speech. I decided to talk about robotics because I couldn't think of anything else to talk about. Initially I wanted to give a speech on how to achieve English proficiency. However, what I didn't realize was that this title was a horrible idea because, well, i'm giving the speech to an English teacher.

  Anyhow, teacher politely suggested that I do something a little bit more interesting, and that's how I ended up talking about robotics. So, without further ado, here's a quick run through of my project.

First robot - Arduino music player

front view of project

internal mechanism

lights above

power source

So basically, the mini figures in the picture will turn around while the familiar tune of twinkle twinkle little stars is being played.
The lights are programmed to turn on after every turn of the servo,
There's a power cable coming out at the back of the project. Once connected, the robot will wait 10 seconds before it opens its doors.
The opening mechanism is powered by rubber bands with a servo acting as a lock.

Second robot - Arduino Magic Robot

Underside of the robot

Shell removed

So, the concept for this robot is simple enough. Use the force to move it.
Well, that's the idea anyways. The robot uses a distance sensor to detect the distance of the hand from the robot. When the hand is at a close enough range, the robot will move accordingly. (We don't want the robot moving when it doesn't detect a hand, would we?)

In case you're wondering why the robots seem so aesthetically dull, it is because I had a very limited time frame to complete this project. Furthermore, the robot will be dismantled after a while and I decided there's not much of a point in decorating it.

Well, that's it. Leave a comment or email me if you have any questions.



Sunday, 31 July 2016

Project BEAST

New school project!
Project Beast was designed in light of a school event. A scissors is attached to the arm of the robot which will extend out to present the scissors.

Saturday, 9 July 2016


Just a casual project for fun. It could walk initially but now it's too heavy due to all the aesthetic pieces.

Sunday, 29 May 2016

Holiday project!

Introducing project AID!
Arduino Intruder Detector

It's a two device setup. There's the actual motion detector and an optional wireless device to monitor everything remotely. There's 4 modes on the motion detector.

1)Alarm mode with no wireless transmitting
2)Silent mode with wireless transmitting
3)Alarm mode and wireless transmitting
4)Range detector

The project is approximately 40% done, there's a bit more coding to do and a hardware casing for the remote monitoring device. First two modes have been completed and it works like a charm, albeit a lot of effort and time was exhausted in trying to get it to work this far. Hopefully I'll be done with this project soon and have a video of it in action uploaded soon. Stay tuned.

Video up!

Friday, 18 March 2016

Custom motor

If you had seen my Arduino RC car video, I mentioned that I wanted to build a faster Arduino car, well, I finally found the 2mm drill bit that I needed and proceeded to drill a hole in the axle and attach the technic axle onto the shaft. If your interested in doing it yourself, you have to first drill a hole in the middle of the axle, maybe halfway through. Make sure it's as straight as possible. Next, you'd want to slot the axle onto the shaft. Then use some super glue to attach it permanently. Make sure not to spread the super glue onto the motor so that it can still spin. Now all  that's left is to attach a lego piece onto the motor frame for easy attachment to other Lego pieces.  I hope to incorporate this motor in some upcoming projects. In the meantime, stay tuned for a cardboard + Mindstorms + Arduino humanoid that I've been working on during the holidays.

Sunday, 13 March 2016

New project! -- ECOBOT

In light of the WRO 2016 competition, our school has held a small competition pertaining to the competition. Here's our team's project:

Brochure for our project



Sunday, 3 January 2016

Upgraded remote

Hmm, I wonder what that button does...

15/1/16: Man have I been busy over the past few days! Form 4 life has been extremely hectic due to the new subjects I was introduced to. There's Biology, Add maths, Chemistry and physics, all resulting in an extremely busy schedule. I truly apologize for the lack of content and for forgetting about working on the RC car. Hopefully I'll be able to squeeze out some time to start working on it asap.