Skip to content

Instantly share code, notes, and snippets.

View abhikpal's full-sized avatar

Abhik Pal abhikpal

View GitHub Profile
@abhikpal
abhikpal / intruderAlert.ino
Last active December 22, 2015 23:59
Code for the talking intruder alert system.
/*
* Arduino Code for
* Simple Talking Intruder Alert System
*
* Abhik Pal
*/
#define pirPin 7 // PIR Sensor connected to pin 7
#define ledPin 13 // LED connected to pin 13
@abhikpal
abhikpal / Arduino_Example_1.ino
Created October 4, 2013 08:40
Code to supplement the "Interfacing Arduino from Processing" Tutorial
/*
* Interfacing Arduino from Processing
* Example 1 Arduino Sketch
*
* The Arduino listens for any data on the serial buffer.
* If any data is received it is stored in a char-variable.
* If the received value is 'H' then the led is turned on and
* if the received value is 'L' then the LED is turned off.
* No action is taken for other values.
*
/*
* Music Visualizer ver2
* This sketch extracts values from the input audio stream
* which happens to give the same values as our output
* stream as "Stereo Mix" has been set as the default device.
* The values are used to draw waveforms representing the
* average, left and right channels and send the values to an
* Arduino which changes the brightness of a LED.
* This is an upgrade to the previous Music Visualizer Project
* at : http://theblubot.blogspot.com/2014/01/simple-music-visualizer.html
/*
* Joystick and the serial monitor.
*
* This sketch outputs data from the joystick at 9600 baud to the 'Serial Monitor' (the serial
* monitor needs to be opened to view this data).
*
* CIRCUIT:
* - Joystick VCC to Arduino 5V, joystick GND to Arduino GND
* - Joystick vertical axis to A0, horizontal to A1
* - Joystick pushbutton connected to digital pin 2 using a pull-up resistor
@abhikpal
abhikpal / obstacle-avoider.ino
Last active September 28, 2016 09:16
Arduino based obstacle avoider robot
/*
* OBSTACLE AVOIDER ROBOT
*
* A simple Arduino based obstacle avoider robot that uses two infrared distance sensors to
* "look for" obstacle and change its behavior accordingly. If the robot detects an obstacle to its
* left, it turns clockwise; if the obstacle is on the right, it turns anti-clockwise; and moves
* forward if no obstacle is found.
*
* Abhik Pal
* (abhik@ardubotics.com)
/*
* BASIC ARDUBOT
*
* A simple Ardubot that demonstrates a basic set of movements.
*
* Abhik Pal
* (abhik@ardubotics.com)
*
* Released under The MIT License (MIT)
*/
/*
* Callibration sketch for the accelerometer.
*
* Simply prints out the values from the x, y, and z axes to the serial monitor. These values can be
* used to calibrate the sensor.
*
* To use this code with the tilt controlled robot, keep the accelerometer flat and then record the
* readings for x and the y axes. The calibrated_x and calibrated_y in the tilt-robot sketch should
* be set to these base values.
*
/*
* LINE FOLLOWER ROBOT
*
* An Arduino based robot that uses an infrared sensor array to follow a line.
*
* Abhik Pal
* (abhik@ardubotics.com)
*
* Released under The MIT License (MIT)
*/
/*
* LIGHT AVOIDER ROBOT
*
* A simple Arduino based obstacle avoider robot that uses two light dependent resistors to
* measure the amount of light in its environment and then move to the area with less light.
*
* Abhik Pal
* (abhik@ardubotics.com)
*
* Released under The MIT License (MIT)
const int num_relays = 8;
const int relays[] = {2, 3, 4, 5, 6, 7, 8, 9};
const int duration = 1000;
void setup() {
for (int i = 0; i < num_relays; i++) {
pinMode(relays[i], OUTPUT);
digitalWrite(relays[i], HIGH);
}