School Project Help

Evening Everyone!

If anyone could help me with the writing of the script I need to operate the group of bits & pieces my local jaycar store helped me purchase for daughters school project I would be so very appreciative.

She has designed a device that is to be used in earthqake zones which will allow a blind to operate on shop shelves once a certain level of vibration has been reached. It will cause an alarm to sound & a light to illuminate prior to the operation of the blind.

The process is out lined below I just need help in wording it into the arduous language to operate it in the correct order.

I have a uno board.

Th vibration Sensor (XC4587) is plugged into port 3 (I can change any of these ports)

I need the following to occur in this order

Signal in from Vibration Sensor exceeds (parameter) - I have no idea on how you measure this or change it)

Sound Alarm -(XC4424) Port 4 on the development Board

and illuminate Light (XC4468) Port 7 on the development Board

2 Second delay

Activate Pull Solenoid (12V operated through a 5V Relay Board XC4419) - This allows the blind to drop The signal is plugged into Port 8 on the UNo Board

2 Second delay

Activate Push Solenoid (12V operated through a 5V Relay Board XC4419) - This locks the blind shut

The signal is plugged into Port 6 on the UNo Board

Finally Alarm stops

(Light will stay illuminated until the reset is pushed)

Feel free to ask any questions - I will try to help

Identical duplicate post deleted.

AWOL:
Identical duplicate post deleted.

and my reply with it. Any chance of resurrecting it and deleting this one instead ?

How did it get deleted - I'm sorry for the confusion, I must have added it into 2 different spots.

I will try & remember what was said & post the links in here now

As asked by Paul to further clarify there will be a blind (made from flyscreen for sake of prototype) that will fall down acrss shelf & preven high value items smashing onto the floor.

The board I have used is the https://www.jaycar.com.au/duinotech-classic-uno/p/XC4410

The vibration module is Linker Vibration Sensor Module for Arduino | Jaycar Electronics
(i have used jumpers to link this to the breadboard)

The buzzer is Arduino Compatible Active Buzzer Module | Jaycar Electronics

The light is Arduino Compatible 3W 200 Lumen LED Module | Jaycar Electronics

The relays - Arduino Compatible 5V Relay Board | Jaycar Electronics

I hope i have understood what Paul meant by posting the links.
Where I refer to the Port numbers these are where i have plugged the jumper cables into the the development board, they are numbered and are on the side of the board where the words digital are written.

Alternatively I will do as Bob suggests & try duplicating a simple code for an LED light, changing the ports etc as i go down the script & if it doesn't work post my attempt at the script back onto a forum post to see if someone can see where i have gone wrong.

Again appreciate your help

How did it get deleted

AWOL deleted one of your 2 identical posts but unfortunately I had already replied to the one he deleted.

This is actually a very simple project that can easily combine elements of the example sketches that come with the IDE. For example, the vibration sensor is a switch, so the switch examples show how to do that. There is a simple sequence of events, triggered by a single event, thus no need for complex timing or multitasking. In fact, there is no reason to put any code in the loop() function as the whole sequence of events waits for a switch closure, and only runs once (I assume it should be a while between different earthquakes). Put all the code in setup().

Approach each device individually, make each work and then just put them in line sequentially using the delay() function for timing.

Try not to do too much of your daughter's work or she won't learn much. Just be a mentor.

Also please stop calling the program a "script". It's really a program, but you can get away with "sketch".

arnoldkr@bigpond.com:
Evening Everyone!

If anyone could help me with the writing of the script I need to operate the group of bits & pieces my local jaycar store helped me purchase for daughters school project I would be so very appreciative.

She has designed a device that is to be used in earthqake zones which will allow a blind to operate on shop shelves once a certain level of vibration has been reached. It will cause an alarm to sound & a light to illuminate prior to the operation of the blind.

The process is out lined below I just need help in wording it into the arduous language to operate it in the correct order.

I have a uno board.

Th vibration Sensor (XC4587) is plugged into port 3 (I can change any of these ports)

I need the following to occur in this order

Signal in from Vibration Sensor exceeds (parameter) - I have no idea on how you measure this or change it)

Sound Alarm -(XC4424) Port 4 on the development Board

and illuminate Light (XC4468) Port 7 on the development Board

2 Second delay

Activate Pull Solenoid (12V operated through a 5V Relay Board XC4419) - This allows the blind to drop The signal is plugged into Port 8 on the UNo Board

2 Second delay

Activate Push Solenoid (12V operated through a 5V Relay Board XC4419) - This locks the blind shut

The signal is plugged into Port 6 on the UNo Board

Finally Alarm stops

(Light will stay illuminated until the reset is pushed)

Feel free to ask any questions - I will try to help

arnoldkr@bigpond.com:
As asked by Paul to further clarify there will be a blind (made from flyscreen for sake of prototype) that will fall down acrss shelf & preven high value items smashing onto the floor.

The board I have used is the https://www.jaycar.com.au/duinotech-classic-uno/p/XC4410

The vibration module is Linker Vibration Sensor Module for Arduino | Jaycar Electronics
(i have used jumpers to link this to the breadboard)

The buzzer is Arduino Compatible Active Buzzer Module | Jaycar Electronics

The light is Arduino Compatible 3W 200 Lumen LED Module | Jaycar Electronics

The relays - Arduino Compatible 5V Relay Board | Jaycar Electronics

I hope i have understood what Paul meant by posting the links.
Where I refer to the Port numbers these are where i have plugged the jumper cables into the the development board, they are numbered and are on the side of the board where the words digital are written.

Alternatively I will do as Bob suggests & try duplicating a simple code for an LED light, changing the ports etc as i go down the script & if it doesn't work post my attempt at the script back onto a forum post to see if someone can see where i have gone wrong.

Again appreciate your help

Hi arnoldkr,

It seems that technically speaking you have what you wanted already....

heres the flow that i can see

There is no Vibration Sensor Value. It's a switch. You just need to wait for an activation.

Thank you all so much!

You have been a massive help - We will look at it tonight when my daughter is at home from school, and will write the program using your helps above,

Apologies on calling it a script - i'm used to using SQL, now i'm clearer around the terminology I'll be more intelligent with my questions,

Again thank you

We have put our script below however it is automatically alarming - i.e. not waiting for any vibration

Where have we gone wrong or how do I adjust the sensitivity?

Appreciate any help that can be given

int switcher = 3;   // Connect Tilt sensor to Pin3 
int Pin8 = 8;       // Connect Buzzer to Pin8
int Pin7 = 7;       // Connect LED  to Pin7
int Pin6 = 6;       // Connect Pull Solenoid to Pin6 Via Relay
int Pin5 = 5;       // Connect Push Solenoid to Pin5 via relay


void setup() 
{ 


pinMode(switcher, INPUT);  // Set digital pin 3 to input mode 
pinMode(Pin8, OUTPUT);     // Set digital pin 8 to output mode
pinMode(Pin7, OUTPUT);     // Set digital pin 7 to output mode
pinMode(Pin6, OUTPUT);     // Set digital pin 6 to output mode
pinMode(Pin5, OUTPUT);     // Set digital pin 5 to output mode  


digitalRead(switcher)==HIGH; //Read sensor value 
digitalWrite(Pin8, HIGH);   // Turn on Buzzer
digitalWrite(Pin7, HIGH);   // Turn on LED 
delay(300);
digitalWrite(Pin6, HIGH);   // Turn on Pull Solenoid
delay(2000);
digitalWrite(Pin5, HIGH);   // Turn on Push Solenoid
delay(10000);
digitalWrite(Pin8, LOW);   // Turn off Buzzer
digitalWrite(Pin7, LOW);   // Turn off LED


  
} 
void loop() 
{ 

}

digitalRead(switcher)==HIGH;What's the point of that?

Please remember to use code tags when posting code

int Pin8 = 8;      // Connect Buzzer to Pin8 Why not call it "buzzerPin", then you wouldn't need the comment?

As requested - Apologies _ i didn't realise there was the code tags

int switcher = 3;   // Connect Tilt sensor to Pin3 
int BuzzerPin = 8; 
int LEDPin = 7;     
int Pin6 = 6;       // Connect Pull Solenoid to Pin6 Via Relay
int Pin5 = 5;       // Connect Push Solenoid to Pin5 via relay


 void setup() 
{ 
 
 
 pinMode(switcher, INPUT);  // Set digital pin 3 to input mode 
 pinMode(BuzzerPin, OUTPUT);     // Set digital pin 8 to output mode
 pinMode(LEDPin, OUTPUT);     // Set digital pin 7 to output mode
 pinMode(Pin6, OUTPUT);     // Set digital pin 6 to output mode
 pinMode(Pin5, OUTPUT);     // Set digital pin 5 to output mode  
 

digitalRead(switcher)==HIGH; //Read sensor value 
digitalWrite(BuzzerPin, HIGH);   // Turn on Buzzer
digitalWrite(LEDPin, HIGH);   // Turn on LED 
delay(300);
digitalWrite(Pin6, HIGH);   // Turn on Pull Solenoid
delay(2000);
digitalWrite(Pin5, HIGH);   // Turn on Push Solenoid
delay(10000);
digitalWrite(BuzzerPin, LOW);   // Turn off Buzzer
digitalWrite(LEDPin, LOW);   // Turn off LED


   
} 
void loop() 
{ 

}

digitalRead(switcher)==HIGH;Still?

The IDE is jam-packed with simple worked examples - why not go through a few?

I'll kickstart you as you seem to have done some work.

 pinMode(switcher, INPUT_PULLUP);  // Set digital pin 3 to input pullup mode
...
...
while (digitalRead(switcher)==HIGH) //Read sensor value
{ } //do nothing

You have to connect the sensor between ground and the input pin.

Thank you aarg - I really appreciate your help

Still?

The IDE is jam-packed with simple worked examples - why not go through a few?

I have tried to look through these & i'm afraid i'm hopelessly lost & unsure what AWOL means. The switch examples use a lot of language i don't understand & i've tried to look the some of it up but i'm just getting hopelessly lost

The only problem I have not been able to resolve is set out below & I visited the electronics store again & have trawled through numerous forum posts and other online code, I would really appreciate any help anyone can give me,

**The device activates immediately after setting it, I have tried adding a 10k Resisitor & and a 220k resistor, (online examples showed setups using these) but then I can't get it to go off at all

You have to connect the sensor between ground and the input pin.

I have moved the GND wire to the GND on the arduino board, it was into a negative hole on the bread board previously, however this still alarms immediately - I wasn't sure if this is what aarg meant ::slight_smile:

Hi,
Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

it will help to understand your code.

Thanks.. Tom... :slight_smile:
Thinks... hmmm an Australian school, I presume, using Arduino to teach tech... revolutionary..
Your daughters school must have a very good IT, tech, electro-mechanical or what ever it is stream.