Heartbeat Simulator with slider

Dear Members,

I am very new on programming and as a project we are trying to create a product that can calculate the CO2 level and work with the help of human powered. But for now on, we do not have an sensor and we are using slider to change the levels manually. We tried to write a kind of code but we totally lost.

What we try to do is;
at low levels = vibration and fading effect of leds will be calm
at mid = a bit excited
at high = fading will and vibration will be fast that shows anger…

I am attaching the code here, the thing we can is just dimming leds and vibration without constantly. :frowning:

Could anybody give me an idea, how can I manage it ?

fadinglights3.pde (1.39 KB)

Your code looks simple, but it’s confusing as to what you exactly try to do. You read some value from 0 to 1024 into threshold. I assume this is the sensor you don’t have any more. Or is it your slider?

Then you write it out to port 10, 11. You write brightness to ports 5 and 6 which is a little curious, as you never set brightness, except in the line commented out. And then you fool around with the variable fadeAmount changing it’s sign constantly.

Although the code probably will compile and do something, the point of what it does doesn’t come across.

So, before going on with this you should properly document, what you want to achieve so that someone else not involved in your project can understand. If you manage this, there’s a very big chance you understand it too and the program will become very simple and obvious.

Here a few questions you should be able to answer:

What inputs do you have?
What is attached to that pin A5?
What range of values do you expect from that input?
What outputs do you have?
What’s attached to those outputs?
What should those output do?
Make a table of input ranges and write down what kind of output you expect for each range.

Once you have that, we can probably help you.

Korman

My inputs are : - 2 leds attached to pin 5 and pin 6 - 1 slider attached to pin analog 5 - vibration motor attached to pins 10 -11 400 = safe level 800 = mid safe level 1024 = danger level

for CO2. Eventhough we have not a sensor yet, we use slider for this

When sensor reads between 0 & 400 values = the product's heart begins to beat calm with fading leds. When sensor reads between 400 & 800 values= the product's heart begins to beat fast with fast fading leds. When sensor reads between 800 & 1024 values= the product's heart begins to beat faster with faster fading leds.

But I do not have any idea the levels of beating and fading will be...

My inputs are : - 2 leds attached to pin 5 and pin 6 LEDs wired to input pins? They are generally wired to output pins and use series resistors

  • 1 slider attached to pin analog 5

  • vibration motor attached to pins 10 -11 One motor wired to input pins 10-11? Again motors are controlled with output pins and usually require switching transistors to handle the current needed for the motor?

The vibration motor we used has 2 output wires, may be for strong frequency…