SparkFun Forums 

Where electronics enthusiasts find answers.

User avatar
By PLVTP
#208555
Hi,


I am a beginner with Arduino so my question my seem basic but I can't make my stuff work without the answer. And I search as much as I could do without finding an answer to this maybe too simple question.

I am more used to Lilypad but I wanted to do a program a bit more complicated and felt the Arduino ProMini will be more suitable.

On the Lilypad, the alimentation is clearly specified by a "+" and a "-". On the Arduino ProMini ATmega328 (3.3V/8MHz), there is no "-" pin.

There is two "GND" pins and I assumed that it would be the equivalent. So, to light a LED, I would connect the + of my LED with pin "4" and the - with the GND pin. And, on every circuit picture I saw, on Sparkfun and elsewhere, it seems to be the case.

But, for one, the LED does not light up, and for two, whenever the circuit is made (- connected to GND and + connected to pin 4), I can no longer push a new code to the Arduino, it returns a error message.

So, my question is, where am I supposed to attach the "-" side of my LED to make it work?

I also take this opportunity to check the following information : I want to add a "power cell" to the ProMini, I assumed that I should connect the VCC from the power cell to the VCC of the ProMini and the GND of the power cell to the GND (next the VCC, right after the RST). Is that correct?

Thank you very much for your help
User avatar
By TS-Mark
#208626
Hi PLVTP,

You are correct in your assumption of hooking up an LED to a digital pin and driving that pin HIGH. Take a look at this example from our Inventor's Kit Guide for a good view of the circuit you want to create. Based on your description, it sounds like you have everything wired up correctly but this will be a good guide to make sure it is. Also, keep in mind that you most likely want to have a current-limiting resistor in series with your LED but since you are driving it from a digital I/O pin, it is not 100% necessary.

I think the issue with the upload may be related to a short you are creating with your LED circuit but I have a few quick questions to get a better idea of your problem. First, can you take a few photos of your Pro Mini and the circuit you have it in with your LED? Please do your best to make sure they are clear and well-lit. Next, what specific error is Arduino printing when you attempt to upload to the board? If possible, can you either copy it and paste it to your reply or take a screenshot of it?

Finally, I am not sure I understand what you are referring to by "power cell". Are you trying to power the Pro Mini and an attached circuit from a USB battery pack or something similar? If so, do you have a specific one you are looking at using? If you are thinking of something different, can you please specify what you are referring to here. Also, unless the voltage coming out of the power cell's VCC pin is exactly 3.3V, you want to connect it to the RAW input, not VCC. RAW will regulate the applied voltage (up to 16VDC) down to either 5V or 3.3V depending on which Pro Mini you are using. If you connect to VCC with anything but the exact voltage the Pro Mini is running at, you may damage the board.
User avatar
By PLVTP
#208655
Thank you very much for your fast and helpful answer. I understood what was wrong and corrected it.

However, I can't read any analog sensor. I use a Arduino Pro Mini 3.3V/8MHz and hook it up to a ADXL 335 (lilypad).

My code (paste below) works with the Lilypad USB but I can't have any reading with Pro Mini (it returns the default value).

I connect the ADXL 335 "-" to GND, the "+" to pin 5 (to replace the "+" pin of the lilypad) and the the Zpin to pin 9.


Edited by moderator to add code tags.
Here is my code :
Code: Select all
// these constants describe the pins.

const int zpin = 9;                  // z-axis 
int alim = 5;                        // sensor alimentation
//
int sampleDelay = 10;               //number of milliseconds between readings


int acceltime = 0;                  // counter


void setup() 
{
 // initialize the serial communications:
 Serial.begin(9600);


 pinMode(zpin, INPUT);  // Z-acceleration input


 pinMode(alim, OUTPUT);   // sensor alimentation as an output

digitalWrite(5, HIGH);    // sensor alimentation always on
}



  void loop() 
{

 //
 int z = analogRead(zpin);  // defining z
 //
 //zero_G is the reading we expect from the sensor when it detects
 //no acceleration.  Subtract this value from the sensor reading to
 //get a shifted sensor reading.
 float zero_G =10; 
 //
 //scale is the number of units we expect the sensor reading to
 //change when the acceleration along an axis changes by 1G.
 //Divide the shifted sensor reading by scale to get acceleration in Gs.
 float scale =1;
 //
 Serial.print(((float)z - zero_G)/scale);
 Serial.print("\t");    // printing the acceleration value 
 //
 // delay before next reading:
 delay(sampleDelay);

Serial.println("on");
     Serial.print("temps d'accéleration:  ");
     Serial.println(acceltime, DEC);    // printing the counter value



  //if loop
if (analogRead(zpin) < zero_G)    // counter reset if Z-acceleration go back to zero
    {
      acceltime=0;
    }
  

    
      if (analogRead(zpin) > zero_G)    // counter increase if there is Z-acceleration 
    {
      acceltime++;
    }

    else {
   
    acceltime=0;    // to make sure counter reset 
    }
  

}
User avatar
By TS-Mark
#208660
If your accelerometer is outputting an analog voltage, it needs to be connected to one of the analog pins on the Pro Mini. Analog pins will be labeled with an A before the pin number (eg. A0, A1, A2 etc.). You can view all of the analog pins on the Pro Mini Graphical Datasheet.