Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Categories > Micro Controllers


Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc.

Reply
 
LinkBack Thread Tools Display Modes
Old 14th August 2008, 11:48 AM   (permalink)
Default Calculator using PIC

Hey, I'm trying to do a simple calculator to add up 2 sets of numbers together using C18.
The number is entered using a keypad and displayed onto the LCD.

Lets say I want to calculate 101 + 50, I would first enter '1', '0', '1' using the keypad. The character '1', would then be stored in the first position of an array followed by '0' and then '1' in the 3rd position of the array. If I want to use the MCU's arithmetic function to add the numbers, i need to convert these characters in the array into 'int variable' of 101.

So, my question is how do I convert character '1', '0', '1' stored in the char array into int 101. Is there any built in function that enables me to do that apart from writting my own code..? Thanks.
MrNobody is offline  
Old 14th August 2008, 11:54 AM   (permalink)
Default

You can convert string to int using the atoi function.
http://www.cplusplus.com/reference/c...dlib/atoi.html

Last edited by colin mac; 14th August 2008 at 11:57 AM.
colin mac is offline  
Old 14th August 2008, 11:59 AM   (permalink)
Default

ah.. thanks for that..
MrNobody is offline  
Reply

Bookmarks

Thread Tools
Display Modes



Similar Threads
Title Starter Forum Replies Latest
calculator chinmay7 Micro Controllers 1 14th October 2007 01:45 PM
calculator sara_6252 Micro Controllers 8 1st June 2007 03:29 AM
Calculator!!! Gaurav Varshney Micro Controllers 1 6th May 2007 07:15 AM
help with Calculator LCD aryyy Micro Controllers 4 17th July 2006 11:25 AM
calculator maria Electronic Projects Design/Ideas/Reviews 2 16th June 2003 05:00 PM



All times are GMT. The time now is 07:53 PM.


Electronic Circuits  |  Learning Electronics
Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.

eXTReMe Tracker