element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      • Japan
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Vietnam
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
IoT on Wheels Design Challenge
  • Challenges & Projects
  • Design Challenges
  • IoT on Wheels Design Challenge
  • More
  • Cancel
IoT on Wheels Design Challenge
Blog IOT on Wheels Design Challenge - Fatigue Alert System (Blog #4)
  • Blog
  • Forum
  • Documents
  • Polls
  • Files
  • Events
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: dwinhold
  • Date Created: 15 Oct 2017 3:23 PM Date Created
  • Views 599 views
  • Likes 2 likes
  • Comments 2 comments
  • iot on wheels
  • fatugue
  • dwinhold
Related
Recommended

IOT on Wheels Design Challenge - Fatigue Alert System (Blog #4)

dwinhold
dwinhold
15 Oct 2017

Hi everyone,

 

For Blog #4 I am attaching the code for the steering wheel touch sensor. Like I mentioned this is for the Arduino and it will be made to run on the Nucleo (When I get the Nucleo working). I am also blogging about the other parts of my project I have been working on.

 

First the code:

 

#include <CapacitiveSensor.h>

CapacitiveSensor   cs_4_8 = CapacitiveSensor(4,8); // 2M resistor between pins 4 & 8, pin 8 is also the sensor pin with the wire to the steering wheel
void setup()                    
{
   cs_4_8.set_CS_AutocaL_Millis(0xFFFFFFFF);
   Serial.begin(9600);
   pinMode(7,OUTPUT);
   pinMode(9,OUTPUT);
}
void loop()                    
{
 long sensor1 =  cs_4_8.capacitiveSensor(50);
    Serial.println(sensor1);  
   if(sensor1 >= 300) // Sensor being touched - No alerts
   {
    digitalWrite(7,LOW);
   }
   else{ // Sensor not touched - Alert activated
    digitalWrite(7,HIGH); // LED lit and alarm activated until sensor touched
    tone(9,500);
    delay(100);
    tone(9,600);
    delay(100);
    tone(9,700);
    delay(100);
    tone(9,800);
    delay(100);
    tone(9,900);
    delay(100);
    tone(9,1000);
    delay(100);
    tone(9,900);
    delay(100);
    tone(9,800);
    delay(100);
    tone(9,700);
    delay(100);
    tone(9,600);
    delay(100);
    tone(9,500);
    delay(100);
    noTone(9);
   }  
}



The other sensors I am working on are as follows:

 

Tilt sensor: This suggestion is from DAB (Thank you for this!!). This sensor will be attached to a head band and will sense if your head tips forward due to nodding off. This is a serious indication that you must stop driving. Attached is the code.

 

int ledPin = 13;               
int switcher = 3;                 
void setup() {
  pinMode(ledPin, OUTPUT);      
  pinMode(switcher, INPUT);      
}
void loop() {
  if (digitalRead(switcher) == HIGH) 
    digitalWrite(ledPin, HIGH);   // Turn on LED and sound alert when the sensor is tilted
    tone(9,500);
    delay(100);
    tone(9,600);
    delay(100);
    tone(9,700);
    delay(100);
    tone(9,800);
    delay(100);
    tone(9,900);
    delay(100);
    tone(9,1000);
    delay(100);
    tone(9,900);
    delay(100);
    tone(9,800);
    delay(100);
    tone(9,700);
    delay(100);
    tone(9,600);
    delay(100);
    tone(9,500);
    delay(100);
    noTone(9);
  else
    digitalWrite(ledPin, LOW);    // Turn off LED and sound alert when the sensor is not triggered
}

 

 

Loud sound sensor:

This is to alert you if someone is honking their horn at you or any other loud noises. This could be from falling asleep at a traffic light and other outside warnings. This sensor will be placed in the trunk of the vehicle.

 

int soundPin = 10; 
int soundVal = HIGH; 
boolean bAlarm = false;
unsigned long lastDetectTime; 
int soundTime = 500; // Number of milli seconds to keep the sound alarm high
void setup ()
{
  Serial.begin(9600);  
  pinMode (soundPin, INPUT) ; // input from sensor
}
void loop ()
{
  soundVal = digitalRead (soundPin) ; // read the sound alarm time

  if (soundVal == LOW) // If we hear a sound
  {

    lastDetectTime = millis(); // record the time of the sound alarm
    if (!bAlarm){
    tone(9,500);
    delay(100);
    tone(9,600);
    delay(100);
    tone(9,700);
    delay(100);
    tone(9,800);
    delay(100);
    tone(9,900);
    delay(100);
    tone(9,1000);
    delay(100);
    tone(9,900);
    delay(100);
    tone(9,800);
    delay(100);
    tone(9,700);
    delay(100);
    tone(9,600);
    delay(100);
    tone(9,500);
    delay(100);
    noTone(9);
      bAlarm = true;
    }
  }
  else
  {
    if( (millis()-lastDetectTime) > soundTime  &&  bAlarm){
      bAlarm = false;
    }
  }
}

 

Next will be creating the vehicle vibration sensor and the vibrating wrist band alert. I am wanting to do the heart rate monitor but I don't think I will be receiving the sensor before the project is to be completed. Hope you enjoyed this update on my project.

 

Thank you

 

Dale W

 

Note: This system can be also used for distracted driving as well (Another very dangerous driving issue)

  • Sign in to reply

Top Comments

  • DAB
    DAB over 8 years ago +2
    Nice update. I agree, distracted driving is a major issue today. I see idiots trying to talk and drive at the same time. Always a bad idea. DAB
  • e14phil
    e14phil over 8 years ago +2
    Looking Good Dale. Please remember to not use any distracting products while on a public road. We want you to complete this challenge in one piece haha!
  • e14phil
    e14phil over 8 years ago

    Looking Good Dale.

    Please remember to not use any distracting products while on a public road. We want you to complete this challenge in one piece haha!

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • DAB
    DAB over 8 years ago

    Nice update.

     

    I agree, distracted driving is a major issue today.

    I see idiots trying to talk and drive at the same time.  Always a bad idea.

     

    DAB

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • More
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2026 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube