Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
10 years, 9 months ago.
Help me to solve my questions below
Using the LEDs on the mbed board, produce the following patterns: ⁃ Flash each LED from left to right, then from right to left, without any lights being on at the same time. Each LED should be turned on for 500 milliseconds, then when the LED switches off, the next LED should light up simultaneously. This process should occur ten times ⁃ Turn the LEDs on for 200 milliseconds in a random order. Each time an LED is switched off, the next LED should light up. Run this process indefinitely.
3. Read temperature data into the mbed and use the LEDs to give a visual indication of the heat data (you should set the range of each LED, based on the observed temperature fluctuation in the room). Make a note of your design decisions. 1. 2.
I gladly help people with problems, however:
1. It is nice if they try something themselves first, or at least mention how they tried to solve it. Now you are just asking us to do your work.
2. We are not here to do your homework, since this really looks like homework. And you didn't get these exercises to let someone else do them.
posted by Erik - 10 Nov 2013Erik +1
posted by Martin Kojtal 10 Nov 2013Thank you sir. I'll get back to you with some of my ideas about the problem. I am very beginner and trying to learn. I really appreciate your comment.
posted by R Poudyal 10 Nov 2013HI Erik, Could you please check my code.
- include “Mbed.h”
Digital out red (p5);
Digital out green (p6);
I2C tempsensor (P9,P10); sda,scl
Serial pc (USBRX); tx,rx
Const int addr = 0x90;
Char config_t[3];
Char temp_read[2];
Float temp;
int main () {
config t[0] = 0x01; set pointer reg to ‘config register’
temp sensor.write (addr,config_t,s); send to printer ‘read temp’
while(1) {
wait(1);
tempsensor.read (addr,temp_read,2); read the two – byte temp data
temp = 0.0625 *(((temp_read)[0]<<8)+temp_read[1]>>4); convert data
pc print (“temp = %2fdegc/n/r”,temp);
if (temp<27) {
red = 1;
green = 0;
{
{
red = 0;
green = 1;
}
}
}
posted by R Poudyal 24 Nov 2013First of all, use
<<code>> and <</code>>
, without it code gets unreadable here.Second, does it work? If it works, then it is probably correct. If it doesn't work, what doesn't work.
posted by Erik - 24 Nov 2013Hi Eric, could you elaborate on your comment "
posted by Kris Falkowski 14 Dec 2013<<code>> and <</code>>
? How is it being done? This format is used, I assume, when one wants to post piece of code on this forum? I am a beginner, too, and will probably have to use the forum in the future, so this would be a helpful skill to have. Thanks.Well skill is a large word. In general you have at the bottom a link with editting tips, which are useful. For code it is simply when you paste some code, put
<<code>> in front of it (on a seperate line), and <</code>>
after it (again on a seperate line). Then it properly formats the code.If you don't do it, you miss of course highlighting of different keywords in your code, but more importantly most line breaks are ignored, it isn't possible to see if stuff is commented out, etc.
posted by Erik - 14 Dec 2013