AllExperts > Qbasic, Quickbasic 
Search      
Qbasic, Quickbasic
Volunteer
Answers to thousands of questions
 Home · More Qbasic, Quickbasic Questions · Answer Library  · Encyclopedia ·
More Qbasic, Quickbasic Answers
Question Library

Ask a question about Qbasic, Quickbasic
Volunteer
Experts of the Month
Expert Login

Awards

About Us
Tell friends
Link to Us
Disclaimer

 
 
 
 
About Alex Barry
Expertise
I have been a qbasic programmer since 2000, creating games, minor libraries and various small programs. I have experience using interrupts, graphics, file input/output, the mouse cursor, and using libraries. I have also learned FreeBASIC, c/c++, python, php and html.
I do not claim to be an absolute authority in any language, but I don't mind looking things up and learning with you.

Experience
Hobby programming since 2000

I no longer belong to any community programming groups, but do have knowledge of *basic dialects and C/C++

 
   

You are here:  Experts > Computing/Technology > Basic > Qbasic, Quickbasic > RAM program

Qbasic, Quickbasic - RAM program


Expert: Alex Barry - 6/12/2009

Question
I have no clue on how to do this RAM program.
Write a program that lets the LED turn on one a time (15 leds) in chronological order and then go backwards. Therefore 15 locations need to be wirtten to and read from. the program must run in a loop.
a sample how the ram works
Out 890, 9 XOR 11
Out 890, 13 XOR 11
Out 890, 9 XOR 11
Out 888, 2^0
Out 890,8 XOR 11
Out 890, 9 XOR 11
Out 890, 11 XOR 11
Out 890, 9 XOR 11


Answer
Hi, Jon,

I haven't tinkered with this sort of thing (LEDs...probably through the parallel port?), but I think I can guide you in the right direction

Right now, I'm assuming that the code given lights up 1 of the LEDs.

So, I'm going to assume this:
1. the first 3 OUT 890 statments prepare the LED
2. the out 888 selects the particular LED you want
3. The remaining OUT statements reset the system for the next LED

If this is true, this will probably work:

declare sub toggleLED( n as integer )

dim i as integer
' Turn on LEDs
for i = 1 to 15
 toggleLED( i )
next i
' Turn off LEDs in reverse
for i = 15 to 1 STEP -1
 toggleLED( i )
next i
end 0

sub toggleLED( n as integer )
 DIM id AS INTEGER
 id = n - 1
 Out 890, 9 XOR 11
 Out 890, 13 XOR 11
 Out 890, 9 XOR 11
 Out 888, 2^( id )
 Out 890,8 XOR 11
 Out 890, 9 XOR 11
 Out 890, 11 XOR 11
 Out 890, 9 XOR 11
end sub

CAUTION: before you test that code out, have your teacher double check it.  With an improper OUT statement, it can either buffer up the parallel port, or the whole computer.  It is very important to double check all any OUT statement code.

If that doesn't help you out, on this section of allexperts, Don may be able to help you more - I'm pretty sure he's had more experience in this area than myself.

Hope that points you in the right direction,
-Alex

Add to this Answer   Ask a Question


 
User Agreement | Privacy Policy | Kids' Privacy Policy | Help
Copyright  © 2008 About, Inc. AllExperts, AllExperts.com, and About.com are registered trademarks of About, Inc. All rights reserved.