Programming Help

Hi,
I’am New to this Micro Controllers Programming, and i am using ATMega 328. i actually do some Sketches - Running Lights back and fort.

But My Question is i need to Execute Another Functions from 1st functions

EX: i copy this Example
int sensorPin = A0;
int ledPin = 13;
int sensorValue = 1000;

void setup() {
pinMode(ledPin, OUTPUT);
}

void loop() {

sensorValue = analogRead(sensorPin);
digitalWrite(ledPin, HIGH);
delay(sensorValue);
digitalWrite(ledPin, LOW);
delay(sensorValue);
// i need to add Call Function here… EX: executePin10();

Function executePin10(); {
Function here
}
}

my question is what is the correct format for the call functions?

Thanks In Advance sorry for my bad english…

// i need to add Call Function here... EX: executePin10();

You're already calling functions called "delay", "pinMode", "analogRead" etc. All you need to do is define the function you want to call.

e.g.

void executePin10() {
//    Function here, note it is "void", so returns nothing
}

Ohh Ok thanks...

is it possible for me to make a Timer on every pin? and how?

I don't understand what you mean by a timer on every pin. Can you explain what you want to do?

amm yah me too hahahaha... because i am usually using visual basic and a PHP coding..

My Main Goal is to make Controller for Human Head.. Eyes Left and Right.. eyebrows up and down.. and mouth expression and Mouth open/close..

i can't start the code because i am confuse even if i read all the examples.. amm what i am needing is to make a full function of that controller.. atleast a basic one..

if led13 = off then { led12 = On // 13 is for Eyes.. 12 is for Eyebrows } If Led11 = off Then { led10 = on // 11 is for mouth expression and 10 is for mouth open close } ...and so on

Btw why i need every pin on and off (delays dependend) because i am using pneumatic air cylinders...

OK, before you go any further, take a look at the blink without delay example in the IDE to see how to control multiple outputs with different timings.

Ok AWOL thanks.. hehe i will be back.. coz i need to use inputs every execution.. xD..

hello again.. ok i make my function structure how can i make ALL LED's or 2 or more LED'S Put on HIGH at same TIME? coz i try all my possible solution but wont work..

ok i make my function structure

I can't see it.

const int buttonPin = 3;
const int ledPin4 = 4;
const int ledPin5 = 5;
int buttonState = LOW;
int outState = 1;
void setup() {
pinMode(ledPin4, OUTPUT);
pinMode(ledPin5, OUTPUT);
pinMode(buttonPin, INPUT);
}
void loop() {
buttonState = digitalRead(buttonPin);
if (buttonState == HIGH) {
outState = 1;
digitalWrite(ledPin4, HIGH);
delay(10000) ;
}
else {
digitalWrite(ledPin4, LOW);
outState = 0;
}
if(outState == 1) {
digitalWrite(ledPin5, HIGH);
delay(100) ;
digitalWrite(ledPin5, LOW);
delay(100) ;
}
}

Sorry for the late reply!

I made that code but the problem is when i trigger the Input 3… the Number 5 Pin Will only light at the half of the delay i setted as 10,000 Milliseconds… What is wrong with the code?

Instead of hi-lighting everything in yellow, use the CODE tags to make it more readable.

I made that code but the problem is when i trigger the Input 3.. the Number 5 Pin Will only light at the half of the delay i setted as 10,000 Milliseconds.. What is wrong with the code?

What do you mean by this? Do you mean that when buttonPin goes HIGH, the led on pin 4 only foes on for 5 seconds?

Much Better if i make like this a word statement

int OutStatus =0;

if Pin3 = High { // This pin3 is the sensor coming from 3rd party device such has LDR or a Motion Sensor OutStatus = 1 delay(####) ; }

if (OutStatus == 1) { Pin4 = high; delay(####) }

Something like this i did not out the right coding but this is more like it..

Something like this i did not make the right coding for this sample but this is more like it..