How do I have two void setups in one program

Iv’e tried to modify the code but I don’t know any replacement voids for void setup, here’s my code. And if you find any problems with it please tell me, I am creating the Love-O-Meter from the guide book as well as project six.

const int sensorPin = A0; // pin that the sensor is attached to
const int ledPin = 9; // pin that the LED is attached to

// variables:
int sensorValue = 0; // the sensor value
int sensorMin = 1023; // minimum sensor value
int sensorMax = 0; // maximum sensor value

void setup() {
// turn on LED to signal the start of the calibration period:
pinMode(13, OUTPUT);
digitalWrite(13, HIGH);

// calibrate during the first five seconds
while (millis() < 5000) {
sensorValue = analogRead(sensorPin);

// record the maximum sensor value
if (sensorValue > sensorMax) {
sensorMax = sensorValue;

// record the minimum sensor value
if (sensorValue < sensorMin) {
sensorMin = sensorValue;

// signal the end of the calibration period
digitalWrite(13, LOW);

void loop() {
// read the sensor:
sensorValue = analogRead(sensorPin);

// apply the calibration to the sensor reading
sensorValue = map(sensorValue, sensorMin, sensorMax, 0, 255);

// in case the sensor value is outside the range seen during calibration
sensorValue = constrain(sensorValue, 0, 255);

// fade the LED using the calibrated value:
analogWrite(ledPin, sensorValue);

Anyway that’s it please help me out I just signed up for this site so I don’t know any tricks.

P.S. Iv’e done programming before but not on Arduino.

You can only have one function named setup. Why do you want two? Just put all the things you want to have happen in setup in the one. Or you could even define a function with the other stuff in it and call it from setup. But it isn't clear why you think you would ever need two of them.

Please read the "How to use this forum - please read" sticky thread at the top of the page and learn the forum rules about how to post code.

Ok srry about the code, it looked smaller when I pasted it.

Ok srry about the code, it looked smaller when I pasted it.

No, don't guess. Freaking read. The issue isn't with the size, but the lack of formatting and tags.

And what about the other, more important questions in my reply?

If you really do need a second setup() function just give it another name such as setupB() and call that from setup()


I don't know any replacement voids

There's no such thing. void just means that the function does not return a value. So "void loop()" means that the function whose name is "loop" does not return a value.