Shop OBEX P1 Docs P2 Docs Learn Events
Please i need a 20-50 line code program for a final — Parallax Forums

Please i need a 20-50 line code program for a final

engconceptsgeekengconceptsgeek Posts: 7
edited 2012-01-05 09:04 in BASIC Stamp
I need a 20-50 line code program that completes some kind of task (car door alarm for example) using one but not limited to infra red sensors, led lights, whiskers, or photoresistors. Just type it out for me

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2011-12-13 17:48
    We cannot help you cheat on a final project / test. There are example programs in the Stamp tutorials. Go to the main Parallax webpage and click on the Downloads button. You'll then see a Stamps in Class Tutorials and Translations button. The What's a Microcontroller? tutorial may have some of what you need. Also look at the tutorials for the BoeBot Robot. Be sure to mention where you got your program. If you claim that something from one of these tutorials is your own work, that's plagerism and is grounds for an F in the course.
  • engconceptsgeekengconceptsgeek Posts: 7
    edited 2011-12-13 18:09
    yes I am aware of what plagarsim is. I needed ideas for help since I have 6 other finals. Many of them AP courses.
  • ercoerco Posts: 20,257
    edited 2011-12-13 18:17
    Type this into the PBASIC editor:

    learn var word
    you con man
    ir var bit
    knowledge=good
    cheat=bad
    school: for you to learn step forward
    for you to help
    if ir=good then learn=1
    if (work.NOT.yourown) then LOW you
    if knowledge=cheat then goto jail
    goto school
    next
    jail:stop:end
  • engconceptsgeekengconceptsgeek Posts: 7
    edited 2011-12-13 18:20
    yeah because I need to know how to work a board of education bot in order to be successful?
  • SRLMSRLM Posts: 5,045
    edited 2011-12-13 18:20
    How much are you paying? Rates here are pretty high, but you'll save some because the work is pretty short.
  • SRLMSRLM Posts: 5,045
    edited 2011-12-13 18:22
    Ok, I have a small program (74 lines) for you. It's pretty simple, let me know if you have any questions.
    import sys
    import math
    import numpy
    from PIL import Image
    
    
    def Decimal2Binary(n):
        '''convert decimal integer n to binary string bStr'''
        bStr = ''
        if n < 0:  raise ValueError, "must be a positive integer"
        if n == 0: return '00000000'
        bstr = ''
        for i in range(8):
        	bstr = str(n % 2) + bstr
        	n = n >> 1
        return bstr
    
    #
    # Open the image file and get the basic information about it.
    #
    try:
        im = Image.open(sys.argv[1])
    except:
        # Eventually this should give more useful information (e.g. file does not
        # exist, or not an image file, or ...
        print "Unable to open %s" % sys.argv[1]
        exit(-1)
    
    
    print "format: %s   mode: %s   palette: %s" % (im.format,im.mode,im.palette)
    width,height = im.size
    print "The image is %d x %d" % im.size
    
    rgbimg = im.convert('RGB')
    
    pixels = list(im.getdata())
    
    #for y in range(height):
    #	for x in range(width):
    #		#print "RGB: %d, %d, %d" %(im.getpixel((x,y)))
    #		#print im.getpixel((x,y))
    #		#for color in im.getpixel((x,y)):
    #			print "%d, %d: " % (x, y), rgbimg.getpixel((x,y))
    #			
    #print "Parsing specific pixel 43, 2: ", rgbimg.getpixel((43, 2))
    
    
    try:
    	coe = open(sys.argv[2], 'w')
    except:
    	print "Unable to open %s" % sys.argv[2]
    	exit(-1)
        
    
    
    coe.write( "memory_initialization_radix = 2;\n")
    coe.write( "memory_initialization_vector = \n")
    
    for y in range(height):
    	for x in range(width):		
    		red, green, blue = rgbimg.getpixel((x, y))
    		red = red & 0b11100000
    		green = green & 0b11100000
    		blue  = blue & 0b11100000
    		output = red | (green >> 3) | (blue >> 6)
    		coe.write( Decimal2Binary(output))
    		coe.write("\n")
    
    coe.close()
    
    #print hex(output)
    
  • SRLMSRLM Posts: 5,045
    edited 2011-12-13 18:26
    I've decided to add another program, just in case the first doesn't work for you. Just type it in and you'll be good to go. It's a bit longer than you wanted (81 lines) but it works, I've tested it out. Let me know if you have more problems than you do already.
    .data
    prompt_e:	.asciiz "\n Please enter the exponent: "
    prompt_m:	.asciiz "\n Please enter the mantissa: "
    prompt_s:	.asciiz "\n Please enter the sign bit: "
    output:         .asciiz "\n Final  Result       Value: "
    
    .text
    main:
    	#clear registers
    	and $t0, $0, $0
    	and $t1, $0, $0
    	and $t2, $0, $0
    	and $t3, $0, $0
    	and $t4, $0, $0
    	and $t5, $0, $0
    	and $t6, $0, $0
    	and $t7, $0, $0
    
    
    	li	$v0, 4	#prepare to syscall print
    	la	$a0, prompt_e
    	syscall
    	
    	li	$v0, 5 #prepare to read int
    	syscall		#get exponent
    	move	$t1, $v0
    
    
    	li	$v0, 4	#prepare to syscall print
    	la	$a0, prompt_m
    	syscall
    	
    	li	$v0, 5 #prepare to read int
    	syscall	       #get mantissa
    	move	$t2, $v0
    
    	#Register allocation:
    	#   $t1 - exponent
    	#   $t2 - mantissa
    
    	#   $t3 - fp number
    
    	#   $t4 - mask
    	#   $t5 - counted shifts
            #   $t6 - working register
    
    	#set up mask
            ori $t4, $0, 1
    	sll $t4, $t4, 31
    
    loop:	
    	and  $t6, $t2, $t4 	#test for upper bit
    	bne  $t6, $0, cont	#if we have shifted so that the upper bit is a 1 then branch
    	sll  $t2, $t2, 1
    	addi $t5, $t5, 1
    	j    loop
    
    cont:    
    	sll  $t2, $t2, 1 #shift out the first one, then shift to mantissa position
    	srl  $t3, $t2, 9
    
    	addi $t6, $0, 31
    	sub  $t6, $t6, $t1 # subtract 31 - exponent
    	sub  $t6, $t6, $t5 # - shift amount
    	addi $t6, $t6, 127
    
    	sll  $t6, $t6, 23
    	or   $t3, $t3, $t6
    	nor  $t4, $t4, $0   	#invert mask
    	and  $t3, $t3, $t4	#clear the upper bit
    
    
    print:
    	li  $v0, 4
    	la  $a0, output
    	syscall
    
    	li $v0, 1
    	move $a0, $t3
    	syscall
    
    	j main
    
  • ercoerco Posts: 20,257
    edited 2011-12-13 18:27
    @SRLM: That's not right to charge him. Heck, he's an AP student with extremely high standards! He's just trying to get the most out of his Board of Education.

    @engconceptsgeek: Pay no attention to these naysayers. I'll do it for free and send it straight to your prof to save you the trouble. What's his name and email address?

    That will free you up to find people to do your other finals for you.
  • SRLMSRLM Posts: 5,045
    edited 2011-12-13 18:29
    Ok, here is a good one. All joking aside, this one is 47 lines of good code. I've run it through a test bench and it passes.
    library IEEE;
    use IEEE.STD_LOGIC_1164.ALL;
    use IEEE.NUMERIC_STD.ALL;
    
    -- Uncomment the following library declaration if instantiating
    -- any Xilinx primitives in this code.
    --library UNISIM;
    --use UNISIM.VComponents.all;
    
    entity scounter32 is
        Port ( clock : in  STD_LOGIC;
               reset : in  STD_LOGIC;
               enable : in  STD_LOGIC;
               count : out  STD_LOGIC_VECTOR (31 downto 0);
               overflow : out  STD_LOGIC);
    end scounter32;
    
    architecture Structural of scounter32 is
    
    	signal internal_count, increment_size : STD_LOGIC_VECTOR(31 downto 0);
    
    
    begin
    
    	--initialization
    	increment_size <= X"00000001";
    	
    
    	--main process
    	main : process(clock, reset, enable) is
    	begin
    		if clock'event and clock='1' then
    			if reset='1' then
    				internal_count <= X"00000000";
    			elsif enable='1' then
    				internal_count <= STD_LOGIC_VECTOR(unsigned(internal_count) + unsigned(increment_size));
    			end if;
    				
    		end if;
    	end process main;
    	
    	count <= internal_count;
    	
    	--set overflow
    	overflow <= '1' when internal_count = X"00000000" and enable='1' else
    					'0';
    
    end Structural;
    
  • ercoerco Posts: 20,257
    edited 2011-12-13 18:32
    That's superb work, SRLM! I really like what you did with STD_LOGIC_VECTOR and I'm sure this young man's prof will also be impressed with that stroke of ingenuity.
  • engconceptsgeekengconceptsgeek Posts: 7
    edited 2011-12-13 18:34
    can anyone write me a simple pulsout 12
    pulsout 13 program that incorporates whiskers or photoresistors?
  • ercoerco Posts: 20,257
    edited 2011-12-13 18:35
    Simple stuff, surely you jest, Sir!
  • engconceptsgeekengconceptsgeek Posts: 7
    edited 2011-12-13 18:46
    no im serious
  • engconceptsgeekengconceptsgeek Posts: 7
    edited 2011-12-13 18:48
    i need something that for example if i were programming a garge door....after the botton is held for three second the led flashes, after five seconds it flashes twice and after 10 seconds flashes three times. but if the connection is lost at any time during the ten second then then programming will not complete
  • ercoerco Posts: 20,257
    edited 2011-12-13 19:36
    If you put the amount of effort you have spent begging for help into learning the material, you'd be done already. Elementary school kids are doing this stuff handily. It's actually fun. Why not do it yourself? What will you learn by getting someone else to do your work for you?
  • engconceptsgeekengconceptsgeek Posts: 7
    edited 2011-12-14 17:55
    because i dont care about robotics. i was forced into this class by the school when i didnt sign up for it. i have 6 other finals to do and dont have time to write this. if your so sick at this and are such a beast just write it lol
  • SRLMSRLM Posts: 5,045
    edited 2011-12-14 18:13
    because i dont care about robotics. i was forced into this class by the school when i didnt sign up for it. i have 6 other finals to do and dont have time to write this. if your so sick at this and are such a beast just write it lol

    It always helps to insult those from whom you are asking a favor.

    We don't help you because we do not, as a forum, condone cheating. Asking for someone else to do your final for you is cheating, and all of us here on the forum have gotten to where we are now by hard work and dedicated effort. It grates on our nerves to see somebody insult us, command us to do something, and not even use decent English.

    I hope that failure will teach you something.
  • mindrobotsmindrobots Posts: 6,506
    edited 2011-12-14 18:39
    What a wonderful life lesson for you! As you grow older and enter the work force, you will be faced with the need to do things and complete projects that you don't lik eor particularly want to do. As long as they don't cause a moral conflict then you will do them since you are being paid to do so or you will fail and quit.

    You are asking us to do something for the sake of helping you that causes us a moral conflict as a group. We won't. If you are mature enough for an AP program, then you should be mature enough to grow through adversity and failure.

    Best of luck in your six other finals!
  • softconsoftcon Posts: 217
    edited 2011-12-15 07:26
    My 9-year old son had no trouble modifying propeller code after a 5-minute explanation from me on what he was looking at. Are you telling me an ap student that has already attended a robotics class can't do what my 9-year old son can do with not a tenth of the same education? I find that hard to believe.
    Spend half an hour with the manuals on your board, and you'll have no problem at all writing your program. And, it may just surprise you how much you actually enjoy the process.
  • Dave HeinDave Hein Posts: 6,347
    edited 2011-12-15 07:58
    Please don't feed the troll.
  • Paul RomskyPaul Romsky Posts: 66
    edited 2012-01-01 17:54
    SRLM,

    You are too funny! Your examples are great. I wonder if this guy actually tried to compile any of the the code you posted [laughing].

    The sad thing is that this guy probably did find someone to do his work for him. There are so many cheaters in the world - it makes me sick.

    Great work!

    Paul
  • SRLMSRLM Posts: 5,045
    edited 2012-01-01 21:05
    SRLM,

    You are too funny! Your examples are great. I wonder if this guy actually tried to compile any of the the code you posted [laughing].

    Great work!

    Paul

    Hey! I've compiled (or synthesized or assembled or ran through the interpreter as appropriate) each of those programs. They work, 100% guaranteed!
  • idbruceidbruce Posts: 6,197
    edited 2012-01-02 01:55
    This is just one of those threads that makes me laugh. I just wonder how many of my previous, but not so brilliant supervisors, have cheated to get to their positions of leadership.

    The greatest reward of cheating is ignorance, and ignorance is bliss. This guy is simply seeking happiness :)

    To charge a battery very quickly, you simply connect the negative terminal to the positive terminal. It won't take long, trust me :)

    Bruce
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2012-01-02 08:36
    Anybody see about the big ETS/SAT test-taking scammer on "60 Minutes" last night?
    The best part is that the company doesn't care, the cheaters are a statistical variance that they can tolerate.
    It's like voting, the same "security", none, to keep it all "accessible".
  • Paul RomskyPaul Romsky Posts: 66
    edited 2012-01-03 17:02
    erco,

    I saw your program and thought it was great. I made some modiciations - you might want to make sure it compiles before we send it to engconceptsgeek. I think this may help out engconceptsgeek with his problem - ok, I felt sorry for him.


    ' {$STAMP BS2}
    ' {$PBASIC 2.5}
    ' { PORT COM1}

    DATA @0, "Program: ", "<TILE OF YOUR PROGRAM HERE>", 0
    DATA " Date: ", "<ENTER DATE HERE>", 0
    DATA " By: ", "<YOUR NAME HERE>", 0

    DATA "!jt!b!MPTFS/" ' Initialization string

    GOOD CON 1
    BAD CON 0
    OK CON GOOD

    man CON GOOD
    learn CON GOOD
    cheat CON BAD

    you VAR Bit
    ask VAR Bit
    yourown VAR Bit
    help VAR Nib
    forward VAR Byte
    work VAR Word
    knowledge VAR Word

    forward = GOOD
    knowledge = GOOD
    help = OK

    yourown = GOOD
    work = 0

    school: FOR you = man TO learn STEP forward
    FOR you = ask TO help STEP GOOD
    IF work = yourown THEN you = learn
    IF NOT yourown = work THEN you = cheat
    IF you = cheat THEN GOTO jail
    GOTO school
    NEXT
    NEXT
    jail: GOSUB jail1 : STOP : END

    jail1:
    work = 0
    help = 0
    booked1:
    READ work, forward
    work = work + 1
    IF forward = 0 THEN GOTO booked2
    DEBUG forward
    GOTO booked1
    booked2:
    DEBUG CR
    help = help + 1
    IF (help = 2) THEN
    DEBUG CR, CR, " "
    GOTO committed
    ENDIF
    GOTO booked1
    committed:
    work = work + 9
    FOR work = work TO 65535
    READ work, forward
    IF forward = 60 THEN
    DEBUG "Author's name was not entered in source code <YOUR NAME HERE> Example: DATA ", 34, " By: ", 34, ", ", 34, "John Smith", 34
    GOTO booked4
    ENDIF
    IF forward = 0 THEN GOTO booked3
    DEBUG forward
    NEXT
    booked3:
    work = work + 1
    FOR work = work TO 65535
    READ work, forward
    IF forward = 47 THEN GOTO booked4
    DEBUG (forward - 1)
    NEXT
    booked4:
    RETURN

    '
    ' End of Program.
    '
  • ercoerco Posts: 20,257
    edited 2012-01-03 19:58
    Much improved over my beta version! :)
  • RiJoRiRiJoRi Posts: 157
    edited 2012-01-05 09:04
    idbruce wrote: »
    ... To charge a battery very quickly, you simply connect the negative terminal to the positive terminal. It won't take long, trust me :)

    Bruce

    Gee, I thought that was how to DIScharge a battery quickly. Or start a fire quickly, especially if you use 0000 steel wool. (Yes, it works. Wanna see my scorched fingertips? :) )

    --Rich
Sign In or Register to comment.