Still working with the Arduino and the TVOut library.

Now I have 3 block falling instead of 1.

Starting to look more like the basics of a game. A bit more coding to do and maybe some buttons to enable the player to actually control something.

Still working with the Arduino and the TVOut library.

Now I have 3 block falling instead of 1.

Starting to look more like the basics of a game. A bit more coding to do and maybe some buttons to enable the player to actually control something.

I was watching the video below and I spotted that the Benchmark BM9 is getting Prime Numbers.

This reminded me of a program I wrote in 1986 (20 I'm old years ago) to work out Primes on an Apple ][ in school.

So, I just had to fire up a BASIC interpreter (BASIC-256) to see if I could recreate it again.

Below is the code I did today with loads of REM comments to explain what I did.

REM Printing the Prime numbers up to 10,000 (maxcheck)

REM Winkleink - 2012

REM Just print the 1st 3 Primes

print 1

print 2

print 3

REM x is what we are checking set x to the next biggest odd number

x=5

REM number up to which we will check for primes

maxcheck = 10000

while x < maxcheck

REM Start the checking with 3 as 1 isn't valid and we are only checking odd number

i = 3

REM Set indicator if prime to 1 (means prime)

isprime =1

REM We only have to check odd numbers up to the Square Root of X as any number that will divide into X evenly will be made up of a number below SQR(x) and 1 above SQR(x)

while i <= int(sqr(x))

REM Check not Prime by seeing if there is a remainder if there is no remainder set isprime to 0

if x/i = int(x/i) then isprime=0

REM If not prime then set i to be above the while loop

if isprime = 0 then i= int(sqr(x))

REM Increment i by 2 as only need to divide by odd

i = i +2

endwhile

REM If isprime is still 1 then it is a prime number

if isprime=1 then print x

REM Increment x by 2,again even numbers won't be prime

x = x +2

endwhile

It was great fun to do and really brought back memories of sitting in the computer room in school watching as it slowly printed out the results. A bit faster today.

And here is a video of it working.

And here is a video of it working.

As always. Code is rough and just done for fun. If you know a better way to calculate primes let me know in the comments.

August last year I posted that I tried the TVOut library with the Arduino but didn't post a video as it was just the usual TVOut demo that I used.

Well, today I again used the standard TVOut Pal Demo but this time something of my own.

We have a NextBase dual screen portable DVD player for keeping the kids occupied in the car. Fantastic invention, would recommend to any parent who has to drive more than an hour with small kids.

While wiring it up I saw the Video port says in/out, so it is Composite, so should work with the Arduino/TVOut combo.

1 re-purposed headphone lead and a couple of resistor later and I had the Arduino outputting video to the NextBase screen.

This means the 14" portable in the garage is now redundant as this is far more compact.

Below is a short video showing it working.

Trying to build up to something actually useful.

Well, today I again used the standard TVOut Pal Demo but this time something of my own.

We have a NextBase dual screen portable DVD player for keeping the kids occupied in the car. Fantastic invention, would recommend to any parent who has to drive more than an hour with small kids.

While wiring it up I saw the Video port says in/out, so it is Composite, so should work with the Arduino/TVOut combo.

1 re-purposed headphone lead and a couple of resistor later and I had the Arduino outputting video to the NextBase screen.

This means the 14" portable in the garage is now redundant as this is far more compact.

Below is a short video showing it working.

I'd suspect there may be many a household with one of these lying around. Either with the DVD player part broken or because the kids have upgraded to a Nintendo or iPad. So, ready to become part of the tinkers box of bits.

Update: I did a bit more coding and managed to creat my own bitmaps and get them to move down the screen. Not a major achievement but a step in the right direction.

The following video shows it. There are 6 bitmaps all 7x7. The program selects a random column to start and then scrolls the graphic down the screen.

Labels:
arduino,
composite,
demo,
dvd player,
electronics,
hack,
nextbase,
portable,
resistors,
tinker,
tvout,
wiring

Subscribe to:
Posts (Atom)