random LED generator

rach

New Member
I'm relatively new to the whole picaxe programming and I'm in desperate need of some expert help!
I need a programme that will randomly select one of eight LED's everytime a switch is pressed. I'm using a PICAXE 18X.
I've read through the manuals and also the dice projects but I only want one of the 8 LEDS to light each time.
I would be so grateful of any help/sugggestions!! If anyone needs any more details on my circuit or anything ask away =]
 

eclectic

Moderator
I'm relatively new to the whole picaxe programming and I'm in desperate need of some expert help!
I need a programme that will randomly select one of eight LED's everytime a switch is pressed. I'm using a PICAXE 18X.
I've read through the manuals and also the dice projects but I only want one of the 8 LEDS to light each time.
I would be so grateful of any help/sugggestions!! If anyone needs any more details on my circuit or anything ask away =]
Welcome to the Forum.

There's loads of info available on this site.

For example,
http://www.picaxeforum.co.uk/showthread.php?t=7799

is a great “random” starter.

Here's a really simple program which might help.
If Pin 1 is high, then it lights the output for one second.

Try it in the simulator first.

Code:
#picaxe 18x

main:
if pin1 = 1 then

 RANDOM w0
 w1 = w0 // 8 + 1
 
 high w1
 pause 1000
 low w1
 goto main
endif 

 goto main
Can you explain more about your
project requirements please?

e
 

rach

New Member
thank you :)

ok its a gcse electronics project, I have done all of the casing, circuit etc but my teacher is away sick so I havn't been able to programme my chip yet. My time is running out and also this problem means the development pages of my project are at a standstill.
Each of the eight LED's represents a player (my project is game) so I want a random player to be chosen each time the switch is pressed.
Is that any more help?
 

eclectic

Moderator
thank you :)

ok its a gcse electronics project, I have done all of the casing, circuit etc but my teacher is away sick so I havn't been able to programme my chip yet. My time is running out and also this problem means the development pages of my project are at a standstill.
Each of the eight LED's represents a player (my project is game) so I want a random player to be chosen each time the switch is pressed.
Is that any more help?
Yes. :)

Which switch (or input pin)
is pressed , to make the decision?

Otherwise, it sounds fairly straightforward. :)

e
 

Mycroft2152

Senior Member
E,

I saw over on the Let's Make Robots site, an interesting idea for a random seed.

Tht trick was to leave a pin floating and even add a small wire to pick up the 60 hz that's always present. Then use the adc to get the value.

Depending on the place in the sine wave, you will get a value to use as the random seed.
 

Rickharris

Senior Member
thank you :)

ok its a gcse electronics project, I have done all of the casing, circuit etc but my teacher is away sick so I havn't been able to programme my chip yet. My time is running out and also this problem means the development pages of my project are at a standstill.
Each of the eight LED's represents a player (my project is game) so I want a random player to be chosen each time the switch is pressed.
Is that any more help?
Just a couple of passing observations from a DT teacher:

1. your GCSE project should have been marked and with the exam board in the Uk by the 5th of may so I guess you are year 10 or year 9 so you have a whole year to complete this?

2. You MUST acknowledge any and all help you get - a legal requirement on the form you will sign at the end of your project so hints are better than answers.

3. The picaxe like most computer systems will not give a truly random output as the sequence repeats - E>G if you restart the programme unless you make some provision to avoid it you will get the same sequence every time - NOTE that for a GCSE project this may not be an issue and WILL NOT be if you note it in your folder.

4. Good luck but I would like to see some programming input from your side to show you are thinking and trying these ideas and applying what you see in the manuals yourself there is a big difference between education (I.E. understanding what you do) and knowledge (knowing a fact.) - Eduction is better!
 
Last edited:

rach

New Member
eclectic - My project is in school at the moment but from my folder I think its Pin 13.


Mycroft2152 - Thank you! I'm doing a spot of research now


Rickharris - Any input I can get from a DT teacher at the moment is appreciated so your comments are really helpful to me. I really don't want someone to just write me a programme, if thats the idea I gave I really didn't mean it like that. I'm not 100% sure whats happening in my school at the moment, as students we don't get told that much. We have been told that the programming isn't vital seeing as we havn't had a teacher for over 6 weeks but it is important to me as my project doesn't seem complete to me if I can't get it working.
I have a mac pc at home so the software for programming isn't available for me yet so all my programming practice has been in school.
 

Rickharris

Senior Member
eclectic - My project is in school at the moment but from my folder I think its Pin 13.


Mycroft2152 - Thank you! I'm doing a spot of research now


Rickharris - Any input I can get from a DT teacher at the moment is appreciated so your comments are really helpful to me. ...
OK - Random will only work well for you if you write it to a word variable - i.e. W1 as this will produce a longer random sequence.

http://www.hippy.freeserve.co.uk/picaxeq2.htm#How_do_I_use_RANDOM

Will help you - If you need 8 LEDS than you only need the lower 8 bits of the word.

Let pins = w1 will set the outputs as you require.


as my project doesn't seem complete to me if I can't get it working.
I have a mac pc at home so the software for programming isn't available for me yet so all my programming practice has been in school.
I guess you are doing the welsh board GCSE electronics paper????


You need to:

1. identify the problem you are going to solve

2. Write a brief - this is a description of the PROBLEM you are going to solve (NOT the solution)

3. Document research into:Existing products that are similiar - Electronic circuits that might generate or display random LEDs - Components, switches, batteries, Pic chips/general IC's, LEDs - Materials

Try to keep this fairly focused rather than trying to pad out your research with general information and annotate everything - Analyse it to say how useful - or not it is.

4. Write a specification (this is a description of your SOLUTION to the problem described in the brief.) This will state what the solution consists of in terms of the functionality BUT does not try to define the actual design i.e. restrict how. try to keep to specific and testable points here because later you will need to test your finished product against this specification.

5. generate several ideas that satisfy the specification - produce some detail investigations and annotate everything - Break the project down into the circuit - The programm (if using a PICaxe) - the case/user interface. If you examine 2 or 3 options in each case 0 e.g. using a picaxe 28 OR a picaxe 18x you will soon have a good range of ideas.

6. Develop your ideas into a finalised solution - PICK THE BEST of the ideas and bring them together into the final design: This will include:
Orthograph drawings of your case showing each part and how the internal parts will be fitted/held in place. Your circuit, the PC/stripboard layout the flow chart and programme. A plan for manufacture giving enough information so a third party could make your project. A material costing sheet.

7. Make the project well and get it working.

8. test your project against you specification and eveluate the outcome (GOOD OR BAD) - suggest ways to improve your project in the future and discuss how a commercial manufacture would make the project in some volume e.g. mass production of PCBs - producing in cheaper countries e.g. China, make the case - injection moulding, market and promote the product.

Does my way work? Well the national pass rate (grades A* to C) for DT in the Uk is about 58% for boys, we get between 98% and 100% every year doing what I have indicated above.

I would add that I have not done the Welsh board for some years so you should download their specification from their web site and read it - it will contain a marking guide your teaching staff will have to apply so you can see what you need to cover in your project.

Good luck.
 

Rickharris

Senior Member
Which exam board and subject are you taking? Although my advice above will still be valid - It seems Welsh board no longer offer electronic products.
 

rach

New Member
It is OCR.
Thanks for all of your advice! It's great and I really appreciate it.
I can't get the link to work though?
 

SilentScreamer

Senior Member
Sorry to hijack but this worries me.

1. your GCSE project should have been marked and with the exam board in the Uk by the 5th
Is this for all exam boards (I am using AQA)? What is the result of missing this deadline?

My GCSE teacher has told us he wants the work tomorrow, he hasn't even seen a single page of mine yet (it's all done, but as my project above his understanding he just says "you'll have it all done").
 

Rickharris

Senior Member
Sorry to hijack but this worries me.



Is this for all exam boards (I am using AQA)? What is the result of missing this deadline?

My GCSE teacher has told us he wants the work tomorrow, he hasn't even seen a single page of mine yet (it's all done, but as my project above his understanding he just says "you'll have it all done").
There is no reason for the Teacher to actually UNDERSTAND what has been done - Few are electronics skilled and fewer are skilled with embedded microprocessor control systems and programming - HOWEVER they can apply the marking guide and give a mark for the work.

The AQA mark submission date is the 5th of May for the students taking the June 2nd exam. We also do the AQA product design course and submitted our marks last Friday.

It is possible for the school to request an extension but that would only be days at the best as the exam board have to select the moderated group if more than 20 entries are made and get those folders to check.

If the deadline is missed by a lot the exam board may refuse the entry at worst you could request to be entered next year (after all its not your fault your teacher has been on long term sick) - It would be up to your Head as to allowing you to do this.

Assessment criteria for Grade B work:

Designing:
1. produced a well ordered and relevant range of appropriate research
information;
2. thoroughly analysed the task and research material;
3. produced a detailed specification closely reflecting the analysis;
4. produced a wide range of proposals which satisfy the specification;
5. used their proposals and relevant knowledge of techniques,
manufacturing and working characteristics of materials to develop a
detailed design solution;
6. planned the correct sequence of making activities;
7. tested, evaluated and modified their work throughout the process as
appropriate;
8. used an appropriate range of communication, graphical and ICT skills
sufficient to convey ideas to themselves and others effectively;
9. provided evidence of having considered relevant issues, industrial
practices and systems and control.

Making:

1. recorded and justified the
need for any changes or
adaptations;
2. used appropriate materials,
components, tools,
equipment and processes
(including CAM) skilfully,
correctly and safely;
3. made a complete, effective
and skilfully-produced
outcome;
4. demonstrated a level of
accuracy and finish in the
product which satisfies the
demands of the design
solution;
5. provided evidence of QA &
QC throughout manufacture

from http://www.aqa.org.uk/qual/gcse/des_tec_sct.php

This is for Systems and Control exam but all the marking guides are similar or common.

The specification also tells you what you need to know for the exam.
 

Rickharris

Senior Member
It is OCR.
Thanks for all of your advice! It's great and I really appreciate it.
I can't get the link to work though?

The link works for me - just click on it - or copy/paste into address box. Hippies page has a link from the links bar at the top of the page here as well.

OCR or AQA as it says on the next page - No matter the system and standards are similar.
 

jc173

Member
Sorry to hijack but this worries me.



Is this for all exam boards (I am using AQA)? What is the result of missing this deadline?

My GCSE teacher has told us he wants the work tomorrow, he hasn't even seen a single page of mine yet (it's all done, but as my project above his understanding he just says "you'll have it all done").
I thought the Deadline was this Thursday? :confused:
 

SilentScreamer

Senior Member
I thought the Deadline was this Thursday? :confused:
You may like me be doing another course, my exam is on the 18th of June. My tutor at school also teaches technology and has said that out deadline is too late (he submitted his classes coursework last week) but he also said its not my fault if its late.

Thanks for the information rick, my teacher has the problem of as he does not understand my project he assumes I can also do my coursework without help, I could write about it for a month and still get very few marks by not "jumping through hoops". Thanks for the link however, I'll find the specification and make sure I have everything included.
 

Rickharris

Senior Member
I thought the Deadline was this Thursday? :confused:
You can check the relevant exam board web site for their dates - None of this is secrete you have access to all the information your teachers have.

With few exceptions the GCSE exam boards all require the preliminary marks in for the 5th of May so they can select the moderated students.

A level work is due on the 15th May or so depending on course and exam board.

Some schools will then get a visit to eyeball the actual projects sometime in mid May to June.

Different exam boards and subjects may have exams on different dates - the course work isn't linked to the exam until they are both marked.
 

rach

New Member
The link works for me - just click on it - or copy/paste into address box. Hippies page has a link from the links bar at the top of the page here as well.

OCR or AQA as it says on the next page - No matter the system and standards are similar.
It keeps navigating away from the page saying broken link before I get a chance to read it. The only page I can seem to get on is http://www.hippy.freeserve.co.uk/. As soon as I click anything else I get just an error page.

Does everyones project get moderated or just a few from each class? We have never been told anything about moderation
 

Rickharris

Senior Member
It keeps navigating away from the page saying broken link before I get a chance to read it. The only page I can seem to get on is http://www.hippy.freeserve.co.uk/. As soon as I click anything else I get just an error page.

Does everyones project get moderated or just a few from each class? We have never been told anything about moderation

try the link from the top of the page to Hippies site. It is working

cut and past this

http://www.hippy.freeserve.co.uk/picaxeq2.htm#How_do_I_use_RANDOM

If the school submit less than 20 entries everyone is moderated. If more than 20 then 20 are chosen by the exam board usually something like top 5 bottom 5 middle 10 - If those marks are considers Ok i.e. fair and correct then no more projects will be examined. The exam board have the right to check every folder but rarly do.
 

SilentScreamer

Senior Member
The above link will not copy as the forum software has shortened the link. Try right clicking on the link and doing "copy link", "copy shorcut" or something simalar, this feature is available in most browsers but not all.
 

Rickharris

Senior Member
try the link from the top of the page to Hippies site. It is working

cut and past this

http://www.hippy.freeserve.co.uk/picaxeq2.htm#How_do_I_use_RANDOM

If the school submit less than 20 entries everyone is moderated. If more than 20 then 20 are chosen by the exam board usually something like top 5 bottom 5 middle 10 - If those marks are considers Ok i.e. fair and correct then no more projects will be examined. The exam board have the right to check every folder but rarly do.


hippy.freeserve.co.uk/picaxeq2.htm#How_do_I_use_RANDOM


This is just text so is correct - you may need to add http://www. at the start.
 
Last edited:
Top