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 / Hi mohammed,this is the code

Hi mohammed,this is the code

|

Microcontroller › 8051 › Calculating flow rate of an infusion pump › Hi mohammed,this is the code

May 16, 2014 at 5:04 pm #11737
venkateshwaran
Participant

Hi mohammed,

this is the code for you.

 

void convert (void)
{
if(sourse<=9) { b = sourse;
c = 0;
d = 0;}
else if(( sourse>= 10) && (sourse<20) ) {
b = sourse – 10 ;
c = 1 ;
d = 0 ; }
else if( (sourse>= 20) && (sourse<30) ) {
b = sourse – 20 ;
c = 2 ;
d = 0 ; }
else if(( sourse>= 30) && (sourse<40) ) {
b = sourse – 30 ;
c = 3 ;
d = 0 ; }

else if(( sourse>= 40) &&( sourse<50 )) {
b = sourse – 40 ;
c = 4 ;
d = 0 ; }
else if( (sourse>= 50) &&(sourse<60) ) {
b = sourse – 50 ;
c = 5 ;
d = 0 ; }
else if( (sourse>= 60) && (sourse<70 )) {
b = sourse – 60 ;
c = 6 ;
d = 0 ; }
else if(( sourse>= 70) &&(sourse<80) ) {
b = sourse – 10 ;
c = 7 ;
d = 0 ; }
else if( sourse>= 80 && sourse<90 ) {
b = sourse – 10 ;
c = 8 ;
d = 0 ; }
else { b = sourse – 10 ;
c = 9 ;
d = 0 ; }
b=0x30|b;
c=0x30|c;
d=0x30|d;}

b is first digit c and d are second and third digits,

this code works only  sourse value is below 100, you can edit this code for

more values. 

RSS Recent Posts

  • The Analog Gods Hate Me July 14, 2025
  • Impact of Tariffs on PCB Fab July 14, 2025
  • More fun with ws2812 this time XC8 and CLC July 14, 2025
  • I Wanna build a robot July 14, 2025
  • Wierd makita battery July 14, 2025

Stay Up To Date

Newsletter Signup
EngineersGarage

Copyright © 2025 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