Things used in this project

Hardware components:
Msp exp432p401r msp exp432p401r sidered eoamulng36
TI LaunchPad MSP-EXP432P401R SimpleLink MSP432 LaunchPad
×1
51gzz5eu9pl. sx425
HC-SR04
×1
color sensor GY-31
×1
Software apps and online services:
Energiabadgelogo2
TI LaunchPad Energia

Code

Main Code - EnergiaArduino
This is main code in Energia. Here are defined all variables that we want to use in other sketches.
/*
 * This tutorial shows how to multithread multiple sensors with Texas Instruments
 * and Energia software. Each Sketch (tab) gets it's
 * own task executing in parallel.
 * Note the names of the setup and loop in these tabs. Energia will look
 * for the keywords with the name setup and loop in it. Each set of matching    setup
 * and loop pairs will automatically create a task for that tab. The loop and setup 
 * names will need to be unigue. So for instance, the Color tab's setup/loop pair are
 * called setupColor() and loopColor(). 
 * Only variables declared in main sketch can be used in other sketches, eg. distance
 * variable can be used in Led sketch, because it's declared in main sketch.
 */

int trig = 38;
int echo = 36;
int elapsed_time, distance;
int frequency1;
int frequency2;
int frequency3;


void setup() {
  pinMode(trig, OUTPUT);
  pinMode(echo, INPUT);
  Serial.begin(9600);
}

void loop() {
    digitalWrite(trig, HIGH); 
    delayMicroseconds(5); 
    digitalWrite(trig, LOW);
    delayMicroseconds(5); 

    elapsed_time = pulseIn(echo, HIGH);
    distance = abs(elapsed_time/2/29.1);
    Serial.println(distance);
    delay(100);
}
ColorArduino
This is sketch for color sensor.
int s0 = 35;
int s1 = 37;
int s2 = 39;
int s3 = 40; 
int out =34;

// Note names for setup() and loop()

void setupColor() {  
  pinMode(s0, OUTPUT);
  pinMode(s1, OUTPUT);
  pinMode(s2, OUTPUT);
  pinMode(s3, OUTPUT);
  pinMode(out, INPUT);
  
  digitalWrite(s0,HIGH);
  digitalWrite(s1,LOW);
}
void loopColor() {
  digitalWrite(s2,LOW);
  digitalWrite(s3,LOW);

  frequency1 = pulseIn(out, LOW);  // This is value for RED
  Serial.println(frequency1);
  delay(100);

  digitalWrite(s2,HIGH);
  digitalWrite(s3,HIGH);

  frequency2 = pulseIn(out, LOW);  // This is value for GREEN
  delay(100);

  digitalWrite(s2,LOW);
  digitalWrite(s3,HIGH);

  frequency3 = pulseIn(out, LOW);  // This is value for BLUE
  delay(100);
}
LedArduino
int led = 33;

void setupLed() {
  pinMode(led, OUTPUT);
}

void loopLed() {
  // You can set any value here for frequency. 
  // Led will turn on if frequency1 (red) is lower than 60
  // and if distance from ultrasonic sensor is lower than 5cm
  
  if (frequency1 < 60 && 0 < distance && distance <= 5){
    digitalWrite(led, HIGH);
  }
  else{
    digitalWrite(led, LOW);
  }
}

Credits

V61kvcen1zt7ktnzhprs
PoliArdo team

Arduino team from Serbia , Belgrade.

Replications

Did you replicate this project? Share it!

I made one

Love this project? Think it could be improved? Tell us what you think!

Give feedback

Comments

Similar projects you might like

Losant with Seeed Studio Grove on MSP432
Easy
  • 274
  • 5

Full instructions

Demonstrate an IoT application connecting Seeed Studio Grove Starter Kit sensors to the Losant IoT cloud platform.

MSP430F5529 LaunchPad + Grove Workshop
Easy
  • 209
  • 2

Protip

The workshop goes through the basics of using LaunchPad, Energia, and Grove Modules for rapid prototyping!

MSP432 Fun with IoT Workshop 2016
Easy
  • 3,021
  • 67

Full instructions

Explore the Educational BoosterPack paired with the MSP432 LaunchPad and then take that to the cloud with the CC3100 Wi-Fi BoosterPack!

MIT IAP 2016 Lab
Easy
  • 1,892
  • 45

A collection of the 6 labs for the MIT IAP Texas Instruments LaunchPad Workshop

Mongoose Embedded Networking Library on mbed+CC3100
Easy
  • 508
  • 12

Protip

Mongoose, the most popular open source embedded web server and networking library now supports the mbed platform. See CC3100 example.

Control a CC3200 LaunchPad with your phone using Blynk
Easy
  • 5,332
  • 26

Full instructions

Read sensor data and toggle LEDs with the Blynk mobile app and the TI CC3200 LaunchPad

ProjectsCommunitiesContestsLiveAppsBetaFree StoreBlogAdd projectSign up / Login
Respect project
Feedback