EngineersGarage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise
You are here: Home / Replies / Ultrasonic interfacing using LPC2148

Ultrasonic interfacing using LPC2148

|

Microcontroller › 8051 › Interfacing AT89S51 with ultrasonic sensor and LCD › Ultrasonic interfacing using LPC2148

October 7, 2015 at 7:54 am #13360
Nilesh Bhavsar
Participant

#include /* LPC21xx definitions */ #include "lcd.h" void LCD_Init(void); unsigned char String1[16]={" iblocks "}; unsigned char String2[16]={" ARM LPC2148 "}; unsigned int ultrasonic_read() { int b; T1TCR = 0x01; T1TC=0; T1PR=0; T1PC=0; IO1SET =(1<<16); // trig pin of ultrasonic sensor Delay1(100); IO1CLR =(1<<16); while((IO1PIN &0x00020000)==0); //echo pin of ultrasonic sensor T1TCR = 0x00; //enable timer while((IO1PIN &0x00020000)==1); T1TCR = 0x01; //stop timer b=T1TC; return b; } int main(void) { unsigned int a; PINSEL0 = 0x00000000; // Enable GPIO on all pins PINSEL1 |= 0x15000000; PINSEL2 = 0x00000000; Delay(20); IO0DIR = (1<<22) | (1<<21) | (1<<20) | (1<<19) | (1<<18) | (1<<17) | (1<<16); // Set P0.16, P0.17, P0.18, P0.19, P0.20, P0.21, P0.22 as Output IO1DIR =(1<<16)|(0<<17); LCD_Init(); // Initialize LCD LCD_Command(0x01); Delay(20); LCD_Command(0x80); LCD_String(&String1[0]); LCD_Command(0xC0); LCD_String(&String2[0]); Delay(200); LCD_Command(0x01); LCD_String("value:"); while(1) { a=ultrasonic_read(); LCD_Command(0xc0); LCDWriteInt(a,3); } }

RSS Recent Posts

  • Win 7 and browsing June 11, 2026
  • Servo Motor Help June 11, 2026
  • Programmable 1kV DC Power Supply – Budget ~$600 with Display June 11, 2026
  • Oshon Basic, programing IF statements June 10, 2026
  • TDK Lambda ESS 500-20-11-D-LB-RSTL Parallel Operation June 10, 2026

Stay Up To Date

Newsletter Signup
EngineersGarage

Copyright © 2026 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy | Advertising | About Us

Search Engineers Garage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise