First timer and hopeful enthusiast

20150307_2038141.jpg (1863621Bytes)

So I go to school at ITT Tech and after turning in our project I now get to mess with the remnants of what we built.  Now what I have built and will put a picture in of is a basic water sensor and arduino package.  This worked fine and the teacher liked it but I have always been worried that the LED was so dim when it turned on that we could barely see it.  The teacher said it was fine and let us go.  I on the other hand am not happy.  I want that LED to work dang it.  Plus, I would also like to make the LED a dc motor instead.  Of course when we plugged it in in a demo to my wife it didnt work besides a tiny tiny little rumble inside the case.  I personally think it is the code that is the problem but I do not have near enough expertise with coding to modify it much more then what I have already done.  Here is the code at the bottom.  And i will try my best to put a picture of my small project too.  Thanks a lot in advance for any insight into my problem.

 

 

 

const int VAL_PROBE = 0; // Analog pin 0

const int MOISTURE_LEVEL = 450; // Analog pin 0 value after LED goes on

 

void setup(){

  Serial.begin(9600); // Set baud rate

}

 

void LedState(int state){

  digitalWrite(13, state);  // Assign pin 13 to the LED

}

 

void loop(){

  int moisture = analogRead(VAL_PROBE);  // Sets moisture to equal the value of the analog pin 0

 

  Serial.println(moisture);

 

  if(moisture > MOISTURE_LEVEL){

    LedState(HIGH);

  } else {

    LedState(LOW);

  }

  delay(100);

}

I can not for the life of me

I can not for the life of me get the second photo into this thread any help would make me grateful.

While I don’t hold bdk’s “Love” of arduinos,

his reply is solid. I ran in to a similar issue with my first robot. The motors wouldn’t turn. Stupid me forgot to set the motor pins as OUTPUTs. DOH!

pinMode(pin, OUTPUT); is the syntax you are looking for. You are not required to set the input pins as INPUT because that is the default.

Also, bdk mentioned the whole driving a motor bit. You need some form of driver to control the motor, even if it is only a resistor, transistor and a snubber diode to turn the motor ON/OFF. A) Most motors draw more current that any one microcontroller pin can supply, B) Voltage spikes when the motor is turned on and off or reversed would likely kill at the very least the pin if not the whole chip.