hello everyone, I was wondering if it is possible to save values of a varialbe for later use, into like a specific location in memory. For example lets say the program is slowly turning an LED that is connected to an I/O port, on and off using pwm. And at random, when a switch is pressed, lets say the LED is 35% ON or 60% ON. and I want to save those random value to memory so that when I press that switch again at a later time.. the LED will be lighted 35% or 60% depending on the value stored in the variable. I am not using HW pwm but software PWM.
I have the leds ramping up and down.. here is what I have so far. just need an idea of how to store the values of the variable for later use.
==============================================
include "modedefs.bas"
Duty VAR Word
Cycle1 VAR BYTE
Switch VAR PortB.1
TRISB = %00000010
Cycle1 = 2
start:
For Duty = 0 to 100
*if(Switch = 1) then
For cycles = 0 to Cycle1
PortB.7 = 0 'LED connected to PIN 7 is off Pauseus 100 - Duty
PortB.7 = 1 'LED in Pin7 is ON
Pauseus Duty
Next cycles
Next Duty
For Duty = 100 to 0 step -1
*if(switch = 1) then
For cycles = 0 to Cycle1 PortB.7 = 1 'LED is ON
Pauseus Duty PortB.7 = 0 ' LEd is turned off Pauseus 100 - Duty
Next cycles
Next Duty
goto Start
====================end of program ==============
here is what I know what to do The Asterick symbol (*) in the program above is where I konw to place the switch statement to check to see if the switch is pressed but I am not sure how to save the value of the variable for later use. I want to make it so taht the values gets presetted, for later use. Any help on this confusion would be greatly appreciated. Thank you in advance
srigopal
Bookmarks