Arduino Data Logging - Dont know where to start

70 Views Asked by At

i have an assignment that is 3 weeks overdue, however my teacher still wants me to hand it up because its worth 15 percent. mine is to use an ultrasonic ranger and an LED bar to measure how close an object gets but i have no idea where to start. please help me!!!

1

There are 1 best solutions below

0
On BEST ANSWER

It depends on the parts you have. Go through the specification sheets for each device and consider how you will communicate with them (such as reading a analogue input or communicating using SPI etc). A quick Google with the device part number should also come up with libraries and example code if it's a popular device.

Also, the complexity of the code depends on the deliverables of the project (i.e. is your code marked or is the functionality only checked)

A simple solution for your code would be a loop and some functions with the following structure:

// declare any variables you need for your processing below

void setup() {
    // Set up your pins here  
}

void loop() {
    ReadRange();

    // process ultrasonic ranger input here 

    OutputLED(/*either pass a variable here or leave the variable global - Loads of ways to run this*/);

    //Add a delay here to slow down the response (if it's very noisy (very dodgy low pass filter)
}

void ReadRange(){
    // code that reads the range using methods that you will research
}

void OutputLED(/*depends if you want to pass variables*/){
    // code that outputs to the LEDs using methods that you will research
}

Edit: So I just thought I would add if you're being marked on coding as well, you could make the variables local to the function and pass them through etc. I won't go into detail as the information is easily available online and I would be teaching you basic coding as a result.