8 years, 3 months ago.

Help with hardware setup - LPC1768

Hello mbed community,

I recently invested in a pack which includes a breadboard, LPC1768 MBED, some wires, resistors, LED's. I have used c++ before and mocked up two little programs which i assume work fine as the logic is only simple. The problem is I am unsure on how to set-up the hardware in relation to the program. The hardware side still baffles me, if i could get some guidance on the hardware set-up such as how to wire it and where the resistors go, i think that it would help me understand it slightly better. Please don't be to technical as i am only 15 and new to electronics. Here are my programs:

Program 1)

Program 1

#include "mbed.h

DigitalOut LED1(p10);
DigitalOut LED2(p11);
DigitalIn Switch(p12);

int main() {
	
	while (1) {
		
		if (Switch == 0) {
			LED1 = 0;     // Turn led1 off.
			LED2 = 1;     // Turn led2 on
			wait(0.5);
			LED2 = 0;
			wait(0.5);
		}

		
		else if (Switch == 1) {
			LED2 = 0;    
			LED1 = 1;  
			wait(0.5);
			LED1 = 0;
			wait(0.5);
		}
	}
}

Program 2)

Program 2

#include "mbed.h

Analogin ain(p15);
DigitalOut LED1(p10);

int main() {
	
	while (1) {
		
if (ain > 0.3f) {
			LED1 = 1;
		} else {
			LED1 = 0;
		}	
}
}

1 Answer

8 years, 3 months ago.

Hi Michael. Welcome to the land of MBED. Have a review of the following website and related webpages which should clarify most of your questions. Feel free to post back if there are additional ones.

https://learn.sparkfun.com/tutorials/light-emitting-diodes-leds

https://learn.sparkfun.com/tutorials/mbed-starter-kit-experiment-guide/introduction

Program 1 - you have defined 2 output pins of p10 and p11 - fine. Locate them on your module and connect a LED to each.

The LED component has a polarity of anode (+) and cathode (-). Anode is the longer lead with the cathode the shorter lead if your part is a leaded part. Many LEDs are available in surface mount as well so review the datasheet if in doubt on the polarity.

Connect the shorter lead (cathode) to p10 and the anode to a current limit resistor so you do not burn out the LED. Too much current will burn out the component instantly. The value of the resistor will define how much current = how bright the LED will glow. A good choice is say 390 ohms and is not super critical so pick any value up to 1k (1000 ohms = Brown Black Red color code). Google for the resistor color code scheme on the net if using leaded parts.

So CATHODE to p10 -> Anode to current limit resistor and the other side of the resistor to +3.3 volts. Proceed to test your program using code to toggle ONLY p10. When the logic is LOW (ie. 0), the LED will glow ON and when p10 is HIGH (ie. 1), the LED will shut off.

Continue to wire up your next LED to p11.

Do review the limits of the voltage you can feed into the controller module if INPUT and respectively the output values when configured as such. The modules are low voltage so read read read else you can quickly damage the very powerful micro you have onboard. Often the voltages are 3.3 volts as a norm but sometimes the modules can be tolerant to higher voltages as the controller will clamp the voltage to a safe value. For example, they do this on the Arduino devices which are operating from 3.3 volts yet are 5 volt tolerant. So while they output 3.3 volts when "1", if configured for input, the voltage could be as high as 5 volts without damage on the Arduino (Atmel processors). Do not attempt this voltage range on your LPC1768.

Experiment away and keep at it. You are in a very interesting field and hope you will agree. Have fun !!

Accepted Answer