Skip to main content

Posts

Showing posts from December, 2013

Snakes&Ladders

This game needs no introduction. Although there are several variations of this game (mainly on position of the snakes and ladders), the rules are generally the same. Some of the rules, (which are part of my algorithm) are mentioned below. Also, this game requires no skill as it solely depends on luck/probability. This allows several mathematical questions relating to this game be answered using Monte Carlo simulation. However, for this post, I will only be investigating from an analytic/subjective stand point. That is, I will be using Markov Chain to answer those questions.
Markov ChainWikipedia link

The game's Markov property or memorylessness allows us to use Markov Chain. That is, the probability of occurrence of next event only depends on current event and not on any other events that occurred before. An example from our game: It does not matter if the player reached square 31 using the ladder from square 9, or by traversing the hard way around. Once the player is in 31, the …

RoomSensors

Temperature and Luminosity sensors using Arduino Instead of sending data from Android to Arduino to perform something like all of my previous projects, this project deals with receiving data from Arduino.

Android Screen-shots:





Arduino//Project: Temperature and Luminosity Readings #include <SoftwareSerial.h>// import the serial library SoftwareSerial newPorts(10, 11); // RX, TXint potPin = 1 ; // pin for temperature sensorint ldr = 3; // pin for ldr sensorvoidsetup() {   newPorts.begin(9600);     pinMode(ldr, INPUT);   pinMode(potPin, INPUT);    newPorts.println("Ready..."); } voidloop() {   while (newPorts.available() > 0)   {        char ch = newPorts.read();     executeReceivedCommand(ch);   } } void executeReceivedCommand(char command) {   switch (command)   {   case'1':     int val;     int dat;    val = analogRead(potPin);     dat = (125*val)>>8 ; // Temperature calculation formula     newPorts.print("Temperature:\n");     newPorts.…

ArduinoProjectUno

Controlling LEDs using an Android device I have wanted to learn Arduino for a while now. However, I also wanted to incorporate Android in there somewhere. This seemed to be a pretty simple start-up project.

Android App























Connecting to Arduino Bluetooth shield On clicking "Connect to Arduino BT", the Android device connects with Arduino. For my purposes, I hard-coded the MAC address of my Arduino Bluetooth in the Android program. 

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20bluetoothConnect.setOnClickListener(new View.OnClickListener(){publicvoidonClick(View v){try{ String macAddress ="20:13:06:26:10:39";if(connect(macAddress)){ greenLED.setVisibility(View.VISIBLE); blueLED.setVisibility(View.VISIBLE); redLED.setVisibility(View.VISIBLE); goRound.setVisibility(View.VISIBLE); showToast("Connected");}}catch(final Exception e){ showToast(e.getMessage());}}}); Sending Characters that mean something to the Arduino
1 2 3 4 …