Chapter 4
e687b491
Posts: 10
in Propeller 1
Please Help
Write a single line of code that sets P8 through P12 to output-high.
Write a repeat loop that sets P0 through P7 to the opposite of the states sensed by P8 through P15. You may want to consult the Propeller Manual’s list of assignment operators for the best option
Write a single line of code that sets P8 through P12 to output-high.
Write a repeat loop that sets P0 through P7 to the opposite of the states sensed by P8 through P15. You may want to consult the Propeller Manual’s list of assignment operators for the best option
Comments
What language are you supposed to write this in?
You should post the code you've tried so far, the results, and why they aren't what you expect.
But since it appears to be homework, I'm not going to give the answer, only to suggest that the OP peruse the Spin reference manual some more.
-Phil
https://www.parallax.com/sites/default/files/downloads/122-32305-PE-Kit-Labs-Fundamentals-Text-v1.2.pdf
The chapter doesn't tell you exactly how to do this but it has pieces that you can put together
For the first one, can you find a line of code that sets a pin to output high, and then can you find code that changes more than one pin at a time?
The second one is more complicated.
First find code that makes a pin an input and then code that gets its value. You can then do this for multiple pins.
Next, there is an OPERATOR that will turn this value into its opposite so look for it. Then use this value to change the output pins.
Finally, look at how REPEAT loops are made and place the code for getting the input, reversing the input, and writing it to the output pins.
The Propeller Manual has a whole section of Spin which is the language that is used in the Propeller Education Kit textbook.
For example, look up the REPEAT command on page 188 and Operators start on page 143.
https://www.parallax.com/sites/default/files/downloads/P8X32A-Web-PropellerManual-v1.2.pdf
Okay, you're right, Phil -- I'll blame my head cold, and that I don't like multi-assignment statements.
If you would like to receive more in-depth advice and/or suggestions from our community members you will need to post your progress so far.