follow the links below to get all the arduino projects you need with ready made codes :) :)
cdn.oreillystatic.com/oreilly/booksamplers/9781449360665_sampler.pdf
tutorial.cytron.com.my/wp-content/uploads/2011/08/User-Manual1.pdf
BasicTutorial
1. Pot Controlled LED's
void setup() {
Serial.begin(9600);
pinMode(0,OUTPUT);
pinMode(1,OUTPUT);
pinMode(2,OUTPUT);
pinMode(3,OUTPUT);
pinMode(4,OUTPUT);
pinMode(5,OUTPUT);
pinMode(6,OUTPUT);
pinMode(7,OUTPUT);
}
void loop() {
int sensorValue = analogRead(A0);
Serial.println(sensorValue);
delay(1);
if(sensorValue==1023)
{
digitalWrite(0,LOW);
digitalWrite(1,LOW);
digitalWrite(2,LOW);
digitalWrite(3,LOW);
digitalWrite(4,LOW);
digitalWrite(5,LOW);
digitalWrite(6,LOW);
digitalWrite(7,LOW);
}
else if( sensorValue == 20)
{
digitalWrite(0,HIGH);
digitalWrite(1,HIGH);
digitalWrite(2,HIGH);
digitalWrite(3,HIGH);
digitalWrite(4,HIGH);
digitalWrite(5,HIGH);
digitalWrite(6,LOW);
digitalWrite(7,HIGH);
}
else if( sensorValue == 50)
{
digitalWrite(0,HIGH);
digitalWrite(1,HIGH);
digitalWrite(2,HIGH);
digitalWrite(3,HIGH);
digitalWrite(4,HIGH);
digitalWrite(5,LOW);
digitalWrite(6,LOW);
digitalWrite(7,HIGH);
}
else if( sensorValue == 100)
{
digitalWrite(0,HIGH);
digitalWrite(1,HIGH);
digitalWrite(2,HIGH);
digitalWrite(3,HIGH);
digitalWrite(4,HIGH);
digitalWrite(5,LOW);
digitalWrite(6,LOW);
digitalWrite(7,LOW);
}
else if(sensorValue == 200)
{
digitalWrite(0,HIGH);
digitalWrite(1,HIGH);
digitalWrite(2,HIGH);
digitalWrite(3,HIGH);
digitalWrite(4,LOW);
digitalWrite(5,LOW);
digitalWrite(6,HIGH);
digitalWrite(7,LOW);
}
else if(sensorValue == 300)
{
digitalWrite(0,HIGH);
digitalWrite(1,HIGH);
digitalWrite(2,HIGH);
digitalWrite(3,HIGH);
digitalWrite(4,LOW);
digitalWrite(5,HIGH);
digitalWrite(6,LOW);
digitalWrite(7,LOW);
}
else if (sensorValue == 500)
{
digitalWrite(0,HIGH);
digitalWrite(1,HIGH);
digitalWrite(2,HIGH);
digitalWrite(3,HIGH);
digitalWrite(4,LOW);
digitalWrite(5,LOW);
digitalWrite(6,LOW);
digitalWrite(7,HIGH);
}
else if (sensorValue == 700)
{
digitalWrite(0,HIGH);
digitalWrite(1,HIGH);
digitalWrite(2,LOW);
digitalWrite(3,LOW);
digitalWrite(4,HIGH);
digitalWrite(5,HIGH);
digitalWrite(6,LOW);
digitalWrite(7,LOW);
}
else if( sensorValue == 900)
{
digitalWrite(0,HIGH);
digitalWrite(1,LOW);
digitalWrite(2,LOW);
digitalWrite(3,LOW);
digitalWrite(4,HIGH);
digitalWrite(5,HIGH);
digitalWrite(6,LOW);
digitalWrite(7,LOW);
}
else if ( sensorValue == 990 )
{
digitalWrite(0,LOW);
digitalWrite(1,LOW);
digitalWrite(2,LOW);
digitalWrite(3,LOW);
digitalWrite(4,LOW);
digitalWrite(5,LOW);
digitalWrite(6,LOW);
digitalWrite(7,HIGH);
}
else
{
digitalWrite(0,HIGH);
digitalWrite(1,HIGH);
digitalWrite(2,HIGH);
digitalWrite(3,HIGH);
digitalWrite(4,HIGH);
digitalWrite(5,HIGH);
digitalWrite(6,HIGH);
digitalWrite(7,LOW);
}
}
2. Dancing Led's
void setup()
{
pinMode(0,OUTPUT);
pinMode(1,OUTPUT);
pinMode(3,INPUT);
pinMode(5,INPUT);
}
void loop()
{
int sw= digitalRead(3);
int sw1= digitalRead(5);
if (sw == LOW)
{
digitalWrite(0,HIGH);
digitalWrite(1,LOW);
}
else if (sw1 == LOW)
{
digitalWrite(0,LOW);
digitalWrite(1,HIGH);
}
else
{
delay(10000);
digitalWrite(0,HIGH);
delay(10000);
digitalWrite(0,LOW);
delay(10000);
digitalWrite(1,HIGH);
delay(10000);
digitalWrite(1,LOW);
}
}
3. Digital Voltmeter Arduino way
int sensorValue = 0;
void setup()
{
pinMode( 0 ,HIGH );
pinMode( 1 ,HIGH );
pinMode( 2 ,HIGH );
pinMode( 3 ,HIGH );
pinMode( 4 ,HIGH );
pinMode( 5 ,HIGH );
pinMode( 6 ,HIGH );
pinMode( 7 ,HIGH );
pinMode( 8,LOW );
}
void loop()
{
int sensorValue=analogRead(A0);
Serial.println(sensorValue);
if (sensorValue==20)
{
delay(1000);
PORTD=0b11000000;
}
else if (sensorValue==50)
{ delay(1000);
PORTD=0b11000000;
}
else if (sensorValue==50)
{ delay(1000);
PORTD=0b11000000;
}
else if (sensorValue==50)
{ delay(1000);
PORTD=0b11000000;
}
else if (sensorValue==50)
{ delay(1000);
PORTD=0b11000000;
}
else if (sensorValue==50)
{ delay(1000);
PORTD=0b11000000;
}
else if (sensorValue==50)
{ delay(1000);
PORTD=0b11000000;
}
else if (sensorValue==50)
{ delay(1000);
PORTD=0b11000000;
}
}
4. Arduino Based Shadow Alarm
// SHADOW ALARM USING ARDUINO //
int rlyPin = 12; // Relay Output Pin
int sensPin = 2; // Sensor Input Pin
int ledPin = 8; // Reminder LED Output Pin
int pzSpeaker = 10; //Piezo-speaker Output Pin
int val = 0; // variable for reading the Input Pin status
void setup() {
pinMode(rlyPin, OUTPUT); // Set Relay as output
pinMode(sensPin, INPUT); // Set Shadow Sensor as input
pinMode(ledPin, OUTPUT); // Set LED as output
pinMode(pzSpeaker, OUTPUT); // Set Piezo-Speaker as output
}
void loop(){
val = digitalRead(sensPin); // read input value
if (val == HIGH) { // check if the input is HIGH
digitalWrite(rlyPin, HIGH); // turn Relay ON
digitalWrite(ledPin,HIGH); // turn LED ON
playTone(500, 600);
delay(100);
playTone(500, 800);
delay(100);
}
else {
digitalWrite(rlyPin, LOW); // turn Relay OFF
playTone(0, 0);
delay(300);
}
}
// duration in mSecs, frequency in hertz
void playTone(long duration, int freq) {
duration *= 1000;
int period = (1.0 / freq) * 1000000;
long elapsed_time = 0;
while (elapsed_time < duration) {
digitalWrite(pzSpeaker,HIGH);
delayMicroseconds(period / 2);
digitalWrite(pzSpeaker, LOW);
delayMicroseconds(period / 2);
elapsed_time += (period);
}
}
5. Pulse Counter using Arduino
void setup()
{
pinMode(0,HIGH);
pinMode(1,HIGH);
pinMode(2,HIGH);
pinMode(3,HIGH);
pinMode(4,HIGH);
pinMode(5,HIGH);
pinMode(6,HIGH);
pinMode(7,HIGH);
pinMode(8,LOW);
}
void loop()
{
delay(1000);
PORTD=0b11000000;
delay(1000);
PORTD=0b11111001;
delay(1000);
PORTD=0b10100100;
delay(1000);
PORTD=0b10110000;
delay(1000);
PORTD=0b10011001;
delay(1000);
PORTD=0b10010010;
delay(1000);
PORTD=0b10000010;
delay(1000);
PORTD=0b11111000;
delay(1000);
PORTD=0b10000000;
delay(1000);
PORTD=0b10011000;
}
Comments
Post a Comment