Chas's security device project

Please take a look at my project, here http://www.youtube.com/watch?v=DFMk1MOY … ata_player

It works with the Arduino, but when uploaded to the Tiny85, gets stuck in a loop …OR the Tiny85 digital input is not recognizing the digital output of the PIR DEVICE.

I am thinking a new multimeter with digital IO might be a good replacement for my 30 year old Micronta … Any recommendations for a good multimeter with digital probe?

the intention is exactly what you see

Loop

intermittent flash of 5-15 secs while monitoring for daylight or nite lux levels which invokes a motion detection routine, which when the PIR goes high, calls a Fn which flashes the lights at strobe-like frequency, until the PIR no longer outputs a digital HIGH


The problem is two-fold.

  1. Why doesn’t the attiny upload, which I know Works on the Arduino, work the same way on the tiny, when I tested the rig against the ATTINY Pinout, on the TinySocket.

  2. Once it Does work, using ONLY the tiny, i need another digital out which the Tiny does not have. Sooo, i would like to add the buzzer back in. Is there a way to turn one of the 3-ADC INPUT channels into a digital output for the buzzer(yes I know it is akin to a speaker, so it could take an analog input, but the routine to run it digitally allows the sound output without any external analog sound sources.)

Code below

Code display:

Code:

code

(alt+c)

Chas

[/img][/*

April 1, 2011 it WORKS ON THE TINY85!!!

programmed with the Tiny shield, using the .0023 ide.

Thanks to all the folks that contributed my understanding!

this experiment takes an initial reading reading from the voltage

devider circuit hooked to the CDS photocell, maps it to a value

of 0-255, then outputs the result a flash to

an array of 21 leds, indicating a change un lux levels.

AtTiny85 pins below

  • digital pin zero is physical pin five (also PWM)

  • digital pin one is physical pin six (also PWM)

  • analogue input two is physical pin seven

  • analogue input three is physical pin two

  • analogue input four is physical pin three

// ATMEL ATTINY85

//AI=Analog Input

// o-/-+

// reset 1| |8 VCC

// Pin 3 (AI 3) PB3 2| |7 PB2 (AI 1) Pin 2

// Pin 4 (AI 2) PB4 3| |6 PB1 PWM Pin 1

// GND 4| |5 PB0 PWM Pin 0

// ±—+

below are the AtTiny85 pins*/

//int ledArray = 0;

//int PIRpin=1; // digital input -HIGH or LOW

//int BuzPin=4; only use this on ardy - tiny has no Dout 4!

//int LDRpin=4;

//boolean LightsOn = false;

//arduino pins below

int ledArray = 11;

int PIRpin=10; // HIGH or LOW

//int BuzPin=PIRpin;

int LDRpin=0;

boolean LightsOn = false;

int LuxRead=0;

int PrevLux=0;

int Pause=50;

int DEBUG = 1; // DEBUG counter; if set to 1, will write values back via serial

unsigned long currentMillis = 0;

unsigned long previousMillis = 0;

void setup()

{

pinMode(PIRpin, INPUT);

pinMode(ledArray, OUTPUT); // sets the pins as output

// sets the pins as output

digitalWrite(LDRpin, HIGH);

if (DEBUG)

{ // If we want to see values for debugging…

Serial.begin(9600); // …set up the serial ouput

}

digitalWrite(ledArray,LOW);

//FlashWhite();

}

void loop()

{

LuxRead = analogRead(LDRpin);

dayORnite(LuxRead) ;//monitor light level

PrintNum(LuxRead,digitalRead(PIRpin),LightsOn);

}

void PrintNum(int newLight,int PIRread,boolean On)

{

if (DEBUG)

{ // If we want serial output, print it at the

Serial.print("Lux: ");

Serial.print(newLight);

Serial.print(" , PIR Val= ");

Serial.print(PIRread);

Serial.print(" , LightsOn = ");

Serial.println(On);

DEBUG += 1;

}

}

void dayORnite(int LightLevel) //monitor light levels

{// now lights are bumping up LightLevel to ~high 40s

if(LightLevel<50 )

{

digitalWrite(ledArray,HIGH);

while(digitalRead(PIRpin)!=1)

{

digitalWrite(ledArray,LOW);

delay(100);

digitalWrite(ledArray,HIGH);

delay(random(5000,15000));

}

ChkMovement();

LightsOn=true;

}

else

{

digitalWrite(ledArray,LOW);

while(digitalRead(PIRpin)!=1)

{

digitalWrite(ledArray,HIGH);

delay(100);

digitalWrite(ledArray,LOW);

delay(random(5000,15000));

}

LightsOn=false;

ChkMovement();

// delay(random(5000,30000));

}

PrintNum(LuxRead,digitalRead(PIRpin),LightsOn);

}

void ChkMovement()

{

if (digitalRead(PIRpin)!=0)//takes~ 30 seconds for PIR to settle

{

FlashWhite();

}

}

void FlashWhite()

{

for (int i=0; i<=2;i++)

{

// if(digitalRead(PIRpin!=1))

// {break;}

digitalWrite(ledArray,LOW);

delay(Pause);

digitalWrite(ledArray,HIGH);

delay(Pause);

digitalWrite(ledArray,LOW);

}// for (int i=0; i<=2;i++)

}// FlashWhite()

][/code]

Chas’s Security Device Project.jpg

Description:

eagle schematic

Filesize: 71.34 KB

Viewed: 24 Time(s)