I am currently using an Arduino Mega with a fast vibration sensor to trigger the components operation (force sensor, temperature sensor) and also toggle sleep mode.

I am very new at this and I have been doing some googling, but I just can't seem to understand it.

So, my questions are:

  1. How would I toggle(on/off) sleep mode?
  2. How would I use interrupts (timer, pin change interrupt?) for an analog pin that triggers when the vibration sensor is triggered, resulting in other components operating?

I am currently working on a Mega, but I will eventually move on to the Arduino Mini Pro. I hope there are no exclusive problems later on.

I realize that this is not a professional question, but I find these tasks very challenging.

Please help me. An example link or perhaps example code to help me understand better.

Thank you very much.

share|improve this question
    
What do you mean by “an analog pin that triggers when the vibration sensor is triggered”? – Edgar Bonet Jan 17 at 10:41
    
so when the vibration sensor gets triggered, then then the analog pin goes out of sleep mode(or the entire board goes out of sleep mode) and the analog pin will start getting inputs from external components in a specific frequency (how much is the analog reading [every 15 sec ]) – Worapat Sopa Jan 26 at 2:31
    
You don't sleep an analog pin, you sleep the CPU. Given your current understanding level, you should really forget about your project for now and focus on learning the basics. Then go through tutorials about sleep mode and interrupts. If you get stuck on your learning process, you can use this site to ask focused questions. Once (and only once) you are comfortable with all that material, you can come back to your original project. You want to run an obstacle course: you should first learn to walk. – Edgar Bonet Jan 26 at 8:37
  1. Have a look at this http://playground.arduino.cc/Learning/ArduinoSleepCode

  2. You can have interrupts on Analog pins of an Uno (I learn something new everyday) http://playground.arduino.cc/Main/PinChangeInterrupt not sure about a mega but I bet Nick Gammon will know.

Practice your google foo young Padawan :)

Seriously, there was nothing wrong with your question, it was clear what you wanted to know and a pleasure to be able to answer. The one improvement you could have made is "an analog pin that triggers an interrupt when the vibration sensor is triggered"

share|improve this answer
    
Thank you very much – Worapat Sopa Jan 26 at 2:28

How would I use interrupts (timer, pin change interrupt?) for an analog pin that triggers when the vibration sensor is triggered, resulting in other components operating?

Thee best and most authoritative answer to that and all your other questions about the chip can be found in thee device data sheet and the compiler manual. Read them thoroughly and then write code to the data sheet to experiment.

Your can fire example have an analog interrupt where the chip constantly does ADC on the pin attached to the sensor and you can test the value of the ADC to see if certain trigger conditions are met and take appropriate actions.

The same with timers, etc. The data sheet is your best friend.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.