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 Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • 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
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • 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
RoadTests & Reviews
  • Products
  • More
RoadTests & Reviews
Blog TI and Würth Elektronik LED RoadTest+ - Project Beta - 4/10
  • Blog
  • RoadTest Forum
  • Documents
  • RoadTests
  • Reviews
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join RoadTests & Reviews to participate - click to join for free!
  • Share
  • More
  • Cancel
  • Author Author: tonyboubady
  • Date Created: 10 Dec 2015 5:30 PM Date Created
  • Views 396 views
  • Likes 4 likes
  • Comments 5 comments
Related
Recommended
  • RoadTest
  • ledroadtestplus
  • würth
  • we
  • elektronik
  • texas_instruments
  • ti

TI and Würth Elektronik LED RoadTest+ - Project Beta - 4/10

tonyboubady
tonyboubady
10 Dec 2015

The real excitement is started and I am really excited about this, yes I have started creating my project and it's in progress. I just wanted to do a beta version of my project before go for main stream, the result was pretty amazing, exactly what I expected to do. My original idea was to use LEDs as ambient sensors, well, it's the thing that hold me to post my blog post for a week, the LEDs not picking up the light accurately, I am getting fluctuation of voltage input in mV which is bad to ADC sampling and I can't get accurate ADC data to process, so, I have decided to flip my sensor usage to LDR (Light Dependent Resistor) from my original idea, surprisingly the result is great.

 

Twist in the Plot

This time I am using CCS cloud as it was an accident that put me in a situation which forced me to search for an alternative IDE, I was ended up in CCS cloud and it's not that bad, to be honest it will help to get things done without sacrificing much. Just keep your development size to small, for dedicated large development CCS desktop app is perfect fit. Ah! well, the accident i am mentioning was literally an accident, my desktop SMPS burned in front my eyes...I had to replace it... now it's working fine.

 

Beta - Wagon

So, the idea is simple to use LDR as ambient sensor to drive my Smart Headlight, I am using 100k resistor with LDR to create voltage divider circuit which is giving data sampling to ADC channel with 3.3v on-board voltage reference. The LDR resistance changes according to the light source and it gives sampling data to A8 ADC channel.

 

image

 

As well, I am using the raw ADC data for processing as it will give much room to calculate data than converting into voltage. if the ADC result is less than 100 which is low LDR resistance, it triggers blue LED, if the ADC result is greater than 150 and less than 400 which is medium LDR resistance, it triggers yellow LED, if the ADC result is greater than 450 which is high LDR resistance, it triggers white LED.

 

image

 

The three LEDs white, yellow and blue are connected to P2.5, P8.2 and P8.3 respectively which is configured as output GPIO pins. The coding is in C...

 

#include <msp430.h>


unsigned int ADC_Result;
int Volt_ADC;
int Volt_Result;


int main(void)
{
    WDTCTL = WDTPW | WDTHOLD;                                // Stop WDT


    // Configure GPIO
    P2DIR |= BIT5;                                          // Set P2.5/LED to output direction
    P2OUT &= ~BIT5;                                          // P2.5 LED off

    P8DIR |= BIT2;                                          // Set P8.2/LED to output direction
    P8OUT &= ~BIT2;                                          // P8.2 LED off

    P8DIR |= BIT3;                                          // Set P8.3/LED to output direction
    P8OUT &= ~BIT3;                                          // P8.3 LED off

    // Configure ADC A8 pin
    SYSCFG2 |= ADCPCTL8;                        


    // Disable the GPIO power-on default high-impedance mode to activate
    // previously configured port settings
    PM5CTL0 &= ~LOCKLPM5;


    // Configure ADC10
    ADCCTL0 |= ADCSHT_2 | ADCON;                            // ADCON, S&H=16 ADC clks
    ADCCTL1 |= ADCSHP;                                      // ADCCLK = MODOSC; sampling timer
    ADCCTL2 |= ADCRES;                                      // 10-bit conversion results
    ADCMCTL0 |= ADCINCH_8;                                  // A8 ADC input select; Vref=AVCC
    ADCIE |= ADCIE0;                                        // Enable ADC conv complete interrupt

    while(1)
    {
        ADCCTL0 |= ADCENC | ADCSC;                          // Sampling and conversion start
        __bis_SR_register(LPM0_bits | GIE);                  // LPM0, ADC_ISR will force exit
        __no_operation();                                    // For debug only

        Volt_ADC = ADC_Result * (3.3/1023);
        Volt_Result = Volt_ADC/11;

        if (ADC_Result > 450) {
            P2OUT |= BIT5;
            P8OUT &= ~BIT2;
            P8OUT &= ~BIT3;
        }
        else if (ADC_Result > 150 && ADC_Result < 400) {
            P2OUT &= ~BIT5;
            P8OUT |= BIT2;
            P8OUT &= ~BIT3;
        }
        else if (ADC_Result < 100) {
            P2OUT &= ~BIT5;
            P8OUT &= ~BIT2;
            P8OUT |= BIT3;
        }
        __delay_cycles(2000);
    }
}


// ADC interrupt service routine
#if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
#pragma vector=ADC_VECTOR
__interrupt void ADC_ISR(void)
#elif defined(__GNUC__)
void __attribute__ ((interrupt(ADC_VECTOR))) ADC_ISR (void)
#else
#error Compiler not supported!
#endif
{
    switch(__even_in_range(ADCIV,ADCIV_ADCIFG))
    {
        case ADCIV_NONE:
            break;
        case ADCIV_ADCOVIFG:
            break;
        case ADCIV_ADCTOVIFG:
            break;
        case ADCIV_ADCHIIFG:
            break;
        case ADCIV_ADCLOIFG:
            break;
        case ADCIV_ADCINIFG:
            break;
        case ADCIV_ADCIFG:
            ADC_Result = ADCMEM0;
            __bic_SR_register_on_exit(LPM0_bits);            // Clear CPUOFF bit from LPM0
            break;
        default:
            break;
    }
}

     

 

Visual Proof

 

 

You don't have permission to edit metadata of this video.
Edit media
x
image
Upload Preview
image

 

It was a successful beta version my next step is to prepare SMD LEDs and circuit board to create Headlight setup. I am on it...in next coming blogs I will show the process of making the Headlight circuit board.

  • Sign in to reply

Top Comments

  • jw0752
    jw0752 over 9 years ago +1
    Nice demonstration Antony. I look forward to your posts. John
  • DAB
    DAB over 9 years ago +1
    Nice post. I look forward to your next update. DAB
  • kenboak
    kenboak over 9 years ago +1
    Hi Antony, Great demonstration. You will see that I have an initial version of SIMPL working on the '4133 Launchpad https://gist.github.com/anonymous/c311dc12afd047ac29f6 I also got a Microchip Curiosity…
  • tonyboubady
    tonyboubady over 9 years ago in reply to kenboak

    Hi Ken, Thanks...

     

    Nice to see you here in E14 community image 

     

    Yes, saw your tweet about that you have successfully ported the SMPL into 4133 image

     

    I am saving the SMPL for right moment I will use it for sure...

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • kenboak
    kenboak over 9 years ago

    Hi Antony,

     

    Great demonstration.

     

    You will see that I have an initial version of SIMPL working on the '4133 Launchpad 

     

    https://gist.github.com/anonymous/c311dc12afd047ac29f6

     

    I also got a Microchip Curiosity board from Farnell (Element 14)  and I hope to port SIMPL across to that - probably at the weekend.

     

     

     

    Ken

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • tonyboubady
    tonyboubady over 9 years ago

    Thank you John and DAB, I am working my way through... I will post soon and often...

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • DAB
    DAB over 9 years ago

    Nice post.

     

    I look forward to your next update.

     

    DAB

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • jw0752
    jw0752 over 9 years ago

    Nice demonstration Antony. I look forward to your posts.

    John

    • Cancel
    • Vote Up +1 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 © 2025 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