Need help Programming for my GCSE Course, and i need it finished by wednesday.

Harambe

New Member
Hello, I am trying to program a 08m2 chip as part of my GCSE Electronics course. I am making an steady hand / Buzz wire game. My circuit has 3 L.E.D.s and a piezo transducer.
I need the program to be able to program the pic chip so that when the wire is touched the first of the 3 L.E.D's is turned on and stays on, then once you touch the wire again, the second L.E.D turns and stays on and then finally once you touch the wire third time, the final L.E.D is lit and all 3 L.E.D's flash a few times and the piezo transducer plays a tune to tell you that it is game over. Furthermore there is a reset button on the circuit to so that once you have lost all lives, you can press the reset button and start all over. when you first turn the circuit on all L.E.D's need to flash a few times to tell the user the game is on and also the piezo needs to play a short tune during this.

All of this needs to be finished by wednesday or my project is incomplete, please help, any questions then please ask. Thankyou!
 

manuka

Senior Member
Harambe: That's an interesting twist on the old steady hand quest. You could possibly refine things by using a single LED that flashes out the number of times touched ? However best you tell us your age, resources, programming & electronic construction skills. Naturally also clarify if outside help is allowed.
Stan. ( New Zealand)
 

Tricky Dicky

Senior Member
Harambe

Any help no matter how little will have to be declared in your evaluation. If you manage to get someone to write the whole program for you then you cannot claim credit for it and you are in no better position then you are in now without a working program. My advice at this stage is to try a bottom up approach and get bits of the program working like switching on the three LEDs in turn in response to the inputs or flashing the LEDs on start up once you have elements of the program working then you can start putting them together into a single program. Why is your teacher not helping you, any help he/she gives does not have to be declared as it would be considered a part of the teaching?

I have to say I feel you have left things a bit late if your project needs to be submitted on Wednesday. On the positive side I have seen students get A-C grades with none or partially functioning circuits depending on the complexity of the project. To maximise your grade now submit your own work as advised above and even if it is not a complete working circuit/program you will get more credit for your own work than simply no credit for someone else's work.

Richard
 

erco

Senior Member
Harambe:

The simple program you describe will practically write itself. Happy to hear you are so far along and enjoying programming your Picaxe 08M2, that's perfect for this job. As well you know, you have your choice of two input pins and four output pins.
 

Buzby

Senior Member
Please post how far you've got up to now, photos, schematic, and code. We can then help you sort it.

As Tricky says, you've left it a bit late !.
 

erco

Senior Member
Harambe: I'll give you one line of the program every day, but you need to ask daily. We should finish in 3-4 weeks. This will get you started:

HIGH 4
 

Goeytex

Senior Member
Looks like this may be a case of a student putting off an assignment until the last minute, and then wanting someone to do it for them while taking credit for the work.

No response by the OP to questions... No indication that the OP has done anything except neglect his course assignment and look for a parachute.

I'll pass on offering any support until I see good evidence that Mr. Harambe has done some homework.
 

ZOR

Senior Member
Harambe, people here want to help you. As Tricky Dicky said, it's no good for you if you just copy whats given to you on a plate, we could all do that but it's cheating. Why not tell us what you have done so far, pictures, circuit. Also what Picaxe you will use. You just say a Pic? We can point you to things in the free download manuals to help you. Even if you don't complete your project you will still get marked on what you had done so far. Come back, don't give up. We all had to learn from nothing. I used to think forums were cold and full of unwilling to help people, but it did me good as I was then forced to learn through helpful pointers. People will want to see you have taken trouble to find things out and not just ask for free handouts. Good luck.
 

Harambe

New Member
I have written 2 programs for the game and neither seem to function properly, I managed to get everything working except that when the wand touches the wire, the l.e.d's do not come on. I am not asking for someone to do the work for me and I have not left it to the last minute, I have been working on. The programme for what seems an eternity and I seem to be no further ahead than when I started. In addition to this my teacher does not seem to be giving anybody any help, I have gotten this far by myself and now it is just the programming that is causing an issue
 

westaust55

Moderator
As already mentioned, post your circuit/schematic diagram AND your almost working code as it currently stands and some folks here may look and provide guidance on how to fix the bugs.
The circuit diagram is essential as so far no one knows what pins you are using for what purpose.
If Wednesday is your deadline the. You have just a couple of days so you need to provide details on what you have done and come back here say hourly (not after more than 24 hours) to see if anyone has some solutions/ideas for you to try.

Might I ask what school you are doing the GCSE at?

As already mentioned by others, often a good mark can be achieved by documenting at that has been done and why you think it does not work. Fully working and excellent write up achieves the top marks.
And as others have also mentioned it is essential you MUST declare how/what help god had by others on this forum. Smart teachers will be checking forums for signs of such help so be honest up front.
 

Goeytex

Senior Member
@Harambe

Post your code and your schematic diagram so that folks can see what you have done so far and what may need to be corrected. If we cannot see the code then there is not much anyone can do to offer an effective solution.
 

manuka

Senior Member
Harambe: Failing posting (& it's assumed you DO know what's involved ?) perhaps directly contact the PICAXE creators -Revolution Education ! Take everything in -they're only down the road from Bristol after all.

I'd say such "source" footwork will go over very well at assessment, even if your circuit is not fully working.
Stan. (40+ years in e-education)
 

Attachments

Harambe

New Member
Hello, thanks for taking the time to reply, unfortunately i am unable to access the code for the program or any of the details until tomorrow which is when i shall add the to the thread, thanks for the help guys!
 

hippy

Technical Support
Staff member
Harambe: Failing posting (& it's assumed you DO know what's involved ?) perhaps directly contact the PICAXE creators -Revolution Education ! Take everything in -they're only down the road from Bristol after all.
Doing that without making an appointment first could easily become a waste of time and effort as people who could help might not be in the office or may be involved with other tasks. We would also not want to create a situation which may give some students an advantage over others in their pursuit of academic qualifications.

We would recommend that any student needing help seeks that through the forum.
 

Harambe

New Member
here are the programs i have already made, neither work though.

Capture.PNG

Program 1

Start:
count=0
high c.2 tune 0, 2, ($00,$02,$04)
high c.1, c.0, c.4
wait 1
low c.1, c.0, c.4
wait 1
high c.1, c.0, c.4
wait 1
low c.1, c.0, c.4
wait 1
high c.1, c.0, c.4
wait 1
low c.1, c.0, c.4
goto main:

Main:
do
if c.4 = 1 then count = +1
if count=1 goto flash1
if count=2 goto flash2
if count=3 goto flash3
else count=0
if count=3 goto reset
loop
end

flash1:
high c.1
wait 1
low c.1
wait
high c.1
end
flash2:
high c.0
wait 1
low c.0
wait 1
high c.0
end
flash3:
high c.4
wait 1
low c.4
wait 1
high c.4
end
reset1:
repeat
if pin c.5 = 1 then c.1, c.4, c.0 low
wait 2
until c.5 = 1









Program 2

startUp:
high c.2 tune 0, 2, ($00,$02,$04)
high c.1, c.0, c.4
wait 1
low c.1, c.0, c.4
wait 1
high c.1, c.0, c.4
wait 1
low c.1, c.0, c.4
wait 1
high c.1, c.0, c.4
wait 1
low c.1, c.0, c.4
goto main:


main:
if pinC.3 high
goto flash:
flash:
high C.1
pause 500
if pinC.3 high
goto flash2
flash2:
high c.0
pause 500
if pinC.3 high
goto flash3
flash3:
high c.4
high C.2 tune 0, 10, ($04,$02,$20)
wait 10
low c.4, c.0, c.1
wait 1
goto reset1
reset1:
if pinC.5 = 1 then main
goto main



Neither circuit works.
 

Jeremy Harris

Senior Member
On the circuit diagram I can see two clear problems. The 10k resistor between the serial input pin and 0V shouldn't be there, as it's likely to upset programming (just remove it, it isn't needed). There's no decoupling capacitors, and the bare minimum is a 0.1uF ceramic (or similar) between the power pins of the 08M2, as close as possible to the pins.

The code has a lot of errors, mainly where labels are being used (anything with a colon after it) where they shouldn't be and lots of goto commands that are not needed - the code will naturally run in sequence from one instruction to the next.

I would suggest that you look at writing down what you want the code to do, as a series of plain English statements, then look at converting each statement into a block of code that will do what you wish. It would also be very useful to carefully read the syntax guidance for each Picaxe instruction you want to use, and look at the simple examples at the start of the manual. Start with just getting something like an LED to flash, to get a feel for how Picaxe BASIC works.
 

Harambe

New Member
On the circuit diagram I can see two clear problems. The 10k resistor between the serial input pin and 0V shouldn't be there, as it's likely to upset programming (just remove it, it isn't needed). There's no decoupling capacitors, and the bare minimum is a 0.1uF ceramic (or similar) between the power pins of the 08M2, as close as possible to the pins.

The code has a lot of errors, mainly where labels are being used (anything with a colon after it) where they shouldn't be and lots of goto commands that are not needed - the code will naturally run in sequence from one instruction to the next.

I would suggest that you look at writing down what you want the code to do, as a series of plain English statements, then look at converting each statement into a block of code that will do what you wish. It would also be very useful to carefully read the syntax guidance for each Picaxe instruction you want to use, and look at the simple examples at the start of the manual. Start with just getting something like an LED to flash, to get a feel for how Picaxe BASIC works.
Hello Jeremy, thanks for the advice, I am going to work on the programming side of it now. I will reply with the final results.
 

Harambe

New Member
startup:
high c.2 tune 0, 2,($00,$02,$04)
high c.1,c.0,c.4
wait 1
low c.1,c.0,c.4
wait 1
high c.1,c.0,c.4
wait 1
low c.1,c.0,c.4
wait 1
high c.1,c.0,c.4
wait 1
low c.1,c.0,c.4

I know this piece of code here works, the L.E.D's flash simultaneously and a short tune is played to signify that the game has been turned on.
 

Harambe

New Member
Hello here is another part to the program, it directly follows the small start up program above.

Code:
[color=Blue]do while [/color][color=Purple]pinc.3 [/color][color=DarkCyan]= [/color][color=Navy]0[/color]
[color=Blue]if [/color][color=Purple]pinc.3 [/color][color=DarkCyan]= [/color][color=Navy]1 [/color][color=Blue]then 
      high c.1
endif [/color][color=Purple]pinc.3 [/color][color=DarkCyan]= [/color][color=Navy]0[/color]
[color=Blue]loop

wait [/color][color=Navy]2[/color]

[color=Blue]do while [/color][color=Purple]pinc.3 [/color][color=DarkCyan]= [/color][color=Navy]0[/color]
[color=Blue]if [/color][color=Purple]pinc.3 [/color][color=DarkCyan]= [/color][color=Navy]1 [/color][color=Blue]then 
      high c.0
endif [/color][color=Purple]pinc.3 [/color][color=DarkCyan]= [/color][color=Navy]0 [/color]
[color=Blue]loop

wait [/color][color=Navy]2[/color]

[color=Blue]do while [/color][color=Purple]pinc.3 [/color][color=DarkCyan]= [/color][color=Navy]0[/color]
[color=Blue]if [/color][color=Purple]pinc.3 [/color][color=DarkCyan]= [/color][color=Navy]1 [/color][color=Blue]then
      high c.4
endif [/color][color=Purple]pinc.3 [/color][color=DarkCyan]= [/color][color=Navy]0[/color]
[color=Blue]loop[/color]
There is a problem however, the L.E.D's do not stay on and I am unsure how to solve this.
 

Harambe

New Member
I think i have completed the circuit program, I do not think there are any problems as it appears to work correctly on the simulator.

Code:
[color=Black]startup:
      [/color][color=Blue]high c.2 tune [/color][color=Navy]0[/color][color=Black], [/color][color=Navy]2[/color][color=Black],[/color][color=Blue]([/color][color=Navy]$00[/color][color=Black],[/color][color=Navy]$02[/color][color=Black],[/color][color=Navy]$04[/color][color=Blue])
      high c.1[/color][color=Black],[/color][color=Blue]c.0[/color][color=Black],[/color][color=Blue]c.4
      wait [/color][color=Navy]1
      [/color][color=Blue]low c.1[/color][color=Black],[/color][color=Blue]c.0[/color][color=Black],[/color][color=Blue]c.4
      wait [/color][color=Navy]1
      [/color][color=Blue]high c.1[/color][color=Black],[/color][color=Blue]c.0[/color][color=Black],[/color][color=Blue]c.4
      wait [/color][color=Navy]1
      [/color][color=Blue]low c.1[/color][color=Black],[/color][color=Blue]c.0[/color][color=Black],[/color][color=Blue]c.4
      wait [/color][color=Navy]1
      [/color][color=Blue]high c.1[/color][color=Black],[/color][color=Blue]c.0[/color][color=Black],[/color][color=Blue]c.4
      wait [/color][color=Navy]1
      [/color][color=Blue]low c.1[/color][color=Black],[/color][color=Blue]c.0[/color][color=Black],[/color][color=Blue]c.4[/color]

[color=Black]flash1:
      [/color][color=Blue]if [/color][color=Purple]pinc.3 [/color][color=DarkCyan]= [/color][color=Navy]1 [/color][color=Blue]then high c.1
      else 
      goto [/color][color=Black]flash1[/color]
[color=Blue]endif

wait [/color][color=Navy]1[/color]

[color=Black]flash2:
      [/color][color=Blue]if [/color][color=Purple]pinc.3 [/color][color=DarkCyan]= [/color][color=Navy]1 [/color][color=Blue]then high c.0
      else
      goto [/color][color=Black]flash2[/color]
[color=Blue]endif

wait [/color][color=Navy]1[/color]

[color=Black]flash3:
      [/color][color=Blue]if [/color][color=Purple]pinc.3 [/color][color=DarkCyan]= [/color][color=Navy]1 [/color][color=Blue]then high c.4
      else
      goto [/color][color=Black]flash3[/color]
[color=Blue]endif

high c.2 tune [/color][color=Navy]0[/color][color=Black],[/color][color=Navy]10[/color][color=Black], [/color][color=Blue]([/color][color=Navy]$04[/color][color=Black],[/color][color=Navy]$02[/color][color=Black],[/color][color=Navy]$20[/color][color=Blue])
low c.1[/color][color=Black],[/color][color=Blue]c.0[/color][color=Black],[/color][color=Blue]c.4
wait [/color][color=Navy]1[/color]
[color=Blue]high c.1[/color][color=Black],[/color][color=Blue]c.0[/color][color=Black],[/color][color=Blue]c.4
wait [/color][color=Navy]1[/color]
[color=Blue]low c.1[/color][color=Black],[/color][color=Blue]c.0[/color][color=Black],[/color][color=Blue]c.4
wait [/color][color=Navy]1[/color]
[color=Blue]high c.1[/color][color=Black],[/color][color=Blue]c.0[/color][color=Black],[/color][color=Blue]c.4
wait [/color][color=Navy]1[/color]
[color=Blue]low c.1[/color][color=Black],[/color][color=Blue]c.0[/color][color=Black],[/color][color=Blue]c.4
wait [/color][color=Navy]1[/color]
[color=Blue]high c.1[/color][color=Black],[/color][color=Blue]c.0[/color][color=Black],[/color][color=Blue]c.4
wait [/color][color=Navy]1[/color]
[color=Blue]low c.1[/color][color=Black],[/color][color=Blue]c.0[/color][color=Black],[/color][color=Blue]c.4[/color]

[color=Black]reset1:
      [/color][color=Blue]if [/color][color=Purple]pinc.5 [/color][color=DarkCyan]= [/color][color=Navy]1 [/color][color=Blue]then goto [/color][color=Black]startup
            [/color][color=Blue]goto [/color][color=Black]reset1
      [/color]
 

erco

Senior Member
Nicely done Harambe, looks like you're well on your way and might be good with your Wednesday deadline. It's wise to add comments after each line (use an apostrophe or semicolon) to spell out your intent. Comments help others understand, and yourself when you look back on your program a month from now.
 

manuka

Senior Member
Program comments (' or ; ) are indeed essential,& the lack of these may well cost marks. As an former e-educator I certainly would downgrade raw code that was not well documented !

I hesitate to further mention colons (":") as their programming use tends bebateable. However Haramabe's code surely will make for cleaner reading if the repetitive code lines are expressed as a single line, with colons between commands. Thus => high c.1,c.0,c.4 : wait 1 : low c.1,c.0,c.4

Naturally there are FAR cleaner PICAXEable ways to tackle the quest, but Harambe hasn't illuminated us tender souls re the exact nature of his course project, OR if external assistance is permitted, or -sigh- even the exact subject...

For those unaware of the level of UK's 15-16 yo. academically rigorous GCSE (General Cert. in Secondary Education),(which may even include myself - having last taught in Britain 1973), perhaps check this past Electronics paper,and associated examiners report.

Stan. in (thankfully !) down under New Zealand
 

AllyCat

Senior Member
Hi,

Just a few issues that might show up when you try the real hardware:

The connections to the "Wand" and "Reset" are marked the wrong way around on the PCB layout in #16.

Also be aware that the "Reset1" section of code is not actually necessary because the PICaxe will perform a "hard reset" as soon as Leg 2 is taken high. There's no harm in showing where the reset is expected occur, but beware that as it's a complete reset (of all variables, etc.) it wouldn't be possible to carry over, for example, a "score" to the next attempt (without using some of the more advanced commands).

Cheers, Alan.
 

westaust55

Moderator
Going back to your two versions of code as posted earlier at post 16.

you will have a syntax error with the lines:
count=0
and others trying to use count as a variable.

This will be for two reasons:
1. You need to use a SYMBOL statement to define the alias for the variable
For example,
SYMBOL wirehits = b0

2. COUNT is a command and thus a reserved word/name, so you cannot use that name for a variable
such as count = 0 and
IF count = 2 then . . . .
Look in PICAXE Manual 2 Appendices 1 and 2 for the lists of reserved words

Finally, again for your count variable you cannot have
IF . . . . THEN count +1
on two counts, :rolleyes:
(a) only a label or GOTO label or GOSUB label can follow the THEN any other commands must start on a new line
(b) +1 is not recognised in PICAXE BASIC (another syntax error in waiting). Try wirehits = wirehits + 1, or INC wirehits

on that note, you can count me out for tonight. :rolleyes:
 
Last edited:

Harambe

New Member
Hello,
I am pleased to say that the program worked... eventually, during inspection I realized that my circuit had a dry joint and this prohibited my circuit from working properly, however after I sorted this simple error the circuit worked perfectly. I thank you all for your help and advice and tips as they have honestly helped me achieve a lot in these last few days, I have learnt a lot about Picaxe programming thank to you guys, p.s you will all be stated as helpful source in my product evaluation.
Kind regards
Harambe / Nick
 

Harambe

New Member
Hi,

Just a few issues that might show up when you try the real hardware:

The connections to the "Wand" and "Reset" are marked the wrong way around on the PCB layout in #16.

Also be aware that the "Reset1" section of code is not actually necessary because the PICaxe will perform a "hard reset" as soon as Leg 2 is taken high. There's no harm in showing where the reset is expected occur, but beware that as it's a complete reset (of all variables, etc.) it wouldn't be possible to carry over, for example, a "score" to the next attempt (without using some of the more advanced commands).

Cheers, Alan.
apologies for that, it is correct on the real circuit, just a mistake on that picture, thankyou.
 

johnlong

Senior Member
Hi Harambe
would a few comments in your code not
go along way to extra brownie points 'ddd
regards
and welcome
john
 

ZOR

Senior Member
Good luck Harambe, glad you got things sorted. Like others suggest, you should do comments after lines of code to explain what that line is doing. The examiner can then read the structure of your code more easily, and of course it helps you when you look at the code later to see the program flow. Glad you did no cheating, does not pay off. Regards
 
Top