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
You are here: Home / Replies / Hi SujitI don’t know how to

Hi SujitI don’t know how to

|

Microcontroller › PIC › Input text in array with push button. › Hi SujitI don’t know how to

September 20, 2016 at 2:24 pm #14144
GANEEV SINGH
Participant

Hi Sujit

I don't know how to work with a PIC but I can surely help you with the logic behind this kind of code.

Lets make it simple by using if-else instructions to check which button has been pressed and then perform the respective task. The code would be somewhat like this:

first of all declare all variables to be used, like

integer variable (say int i=0,j=64;)    //characters' ASCII value start from 65=90, check it out.

character string (say char arr[10];)

if(button 1 pressed)

{

if(j==90) //char is 'Z'

{j=65}    //char becomes 'A'

else

{j++;}     //increment char

arr=j;  //put char value in string's ith position

}

else if(button 2 pressed)

{

if(j==65 || j==64)   //char is either 'A' or its ASCII value is 64

{j=90}  //char becomes 'Z'

else

{j–;}

arr=j;

 

}

else if(button 3 pressed)

{

i++;   //increment string's position

}

else if(button 4 pressed)

{

arr[i+1]='';  //close the string with a null character

i=0;   //reset i's value to 0

//also here you should include a code which will store this string on eeprom of PIC

} 

You can adjsut the string size according to your need and look out for some code that will help you to store string in eeprom. Try searching out at EGs search bar (top right corner).

You can also write a code to print this process on LCD, just add the LCDdisplay() lines just after if-else instructions.

This might hlep you. Good luck!!

RSS Recent Posts

  • Can I use an SPDT 5 wire Relay in reverse? August 9, 2022
  • Basic questions about MOSFETS, Gate Drivers and Diodes August 9, 2022
  • LTSpice DC-AC August 9, 2022
  • Circuit Problem August 8, 2022
  • Google translate suggest "device sheet" or "apparatus sheet" but that cannot be ? August 8, 2022

Stay Up To Date

Newsletter Signup
EngineersGarage

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