Using Functions

I need help with this code, it compiles but it doesn't work on my circuit, i have ,made sure everything is okay. Help me please (here's the code)

const int buttonPin1 = 12; const int buttonPin = 11; int buttonstate = 0; int buttonstate1 = 0; int potPin = 1; // select the input pin for the potentiometer const int ledPin = 2; const int ledPin1 = 8; const int ledPin2 = 6; const int ledPin3 = 5;// select the pin for the LED int val = 0;

void setup() { pinMode(buttonPin,INPUT); pinMode(buttonPin1,INPUT); pinMode(ledPin,OUTPUT); // declare the ledPin as an OUTPUT pinMode(ledPin1,OUTPUT); pinMode(ledPin2,OUTPUT); pinMode(ledPin3,OUTPUT); } void One() { buttonstate = digitalRead(buttonPin1); if (buttonstate1 == HIGH) { Two; } } void Two () { val = analogRead(potPin); // read the value from the sensor digitalWrite(ledPin, HIGH); digitalWrite(ledPin1, LOW); digitalWrite(ledPin2, HIGH); digitalWrite(ledPin3, LOW);// turn the ledPin on delay(val); // stop the program for some time digitalWrite(ledPin, LOW); digitalWrite(ledPin1, HIGH); digitalWrite(ledPin2, LOW); digitalWrite(ledPin3, HIGH); // turn the ledPin off delay(val);

} void loop() { buttonstate = digitalRead(buttonPin); if (buttonstate == HIGH) { One; } }

if (buttonstate == HIGH)
  {
    One;
  }

Functions are called with brackets, thus:

if (buttonstate == HIGH)
  {
    One ();
  }

Use code tags next time please, not the "copy for forum" feature.

Read this before posting a programming question

Thank you for helping me out :)

Bookmark some useful pages: http://arduino.cc/en/Tutorial/Foundations http://arduino.cc/en/Tutorial/HomePage http://arduino.cc/en/Reference/HomePage http://www.nongnu.org/avr-libc/user-manual/modules.html

You will refer to these again and again getting started.

That first link has links to these subjects:

Foundations

This page contains explanations of some of the elements of the Arduino hardware and software and the concepts behind them. Basics

Sketch: The various components of a sketch and how they work.

Microcontrollers

Digital Pins: How the pins work and what it means for them to be configured as inputs or outputs.

Analog Input Pins: Details about the analog-to-digital conversion and other uses of the pins.

PWM: How the analogWrite() function simulates an analog output using pulse-width modulation.

Memory: The various types of memory available on the Arduino board.

Programming Technique

Variables How to define and use variables.

Functions: How to define and use functions.

Libraries: How to write your own library.

Circuits

Arduino on a Breadboard: Using the microcontroller from an Arduino on a breadboard.

You will want to bookmark a good web tutorial or two as well, search C++ tutorial on Google and pick one(s) that you find readable.

Before the net, we had to buy or borrow books. I still have a few. If you have a good used or surplus/wholesale book store anywhere near by it can be worth checking out from time to time. You can generally find them near colleges and universities but with the net, browser tabs and Save Page As there is very little need.