Friday 2 December 2016

Pet Feeder

Just a simple holiday project.

Check it out:


Code: https://drive.google.com/open?id=0B6uB9kVTUBKuWFZQUDFBX1pjRW8

Tuesday 15 November 2016

Python + Arduino Project

PROJECT VOC

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.
Serial.println(yval);
delay(10);

}


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 = color.green, 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.

https://drive.google.com/open?id=0B6uB9kVTUBKuWFZQUDFBX1pjRW8

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.

https://drive.google.com/open?id=0B6uB9kVTUBKudmRjX2NFeWRkdlE

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.

code: https://drive.google.com/drive/folders/0B6uB9kVTUBKuWFZQUDFBX1pjRW8


                                    




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

Humanoid

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