955
In this example we will display some of the scrolling text examples on a codebug, these are easy to create
Code
Python
# To run this code on CodeBug, visit: # # http://www.codebug.org.uk/learn/activity/66/tethering-codebug-with-python/#step585 # import codebug_tether from codebug_tether import (IO_DIGITAL_OUTPUT, IO_DIGITAL_INPUT, IO_PWM_OUTPUT, IO_ANALOG_INPUT) from codebug_tether.sprites import StringSprite codebug = codebug_tether.CodeBug() codebug.set_leg_io(0, IO_DIGITAL_INPUT); codebug.set_leg_io(1, IO_DIGITAL_INPUT); codebug.set_leg_io(2, IO_DIGITAL_INPUT); codebug.set_leg_io(3, IO_DIGITAL_INPUT); codebug.set_leg_io(4, IO_DIGITAL_INPUT); codebug.set_leg_io(5, IO_DIGITAL_INPUT); codebug.set_leg_io(6, IO_DIGITAL_INPUT); codebug.set_leg_io(7, IO_DIGITAL_INPUT); codebug.scroll_sprite(StringSprite('Hello World!', 'R'), 100/1000, 'L') codebug.scroll_sprite(StringSprite('Hello World!', 'R'), 100/1000, 'R') codebug.scroll_sprite(StringSprite('Hello World!', 'D'), 100/1000, 'U') codebug.scroll_sprite(StringSprite('Hello World!', 'U'), 100/1000, 'D')
Javascript
codebug_direction('U'); codebug_sleepafter(3); io_configure(0, IO_DIGITAL_INPUT); io_configure(1, IO_DIGITAL_INPUT); io_configure(2, IO_DIGITAL_INPUT); io_configure(3, IO_DIGITAL_INPUT); io_configure(4, IO_DIGITAL_INPUT); io_configure(5, IO_DIGITAL_INPUT); io_configure(6, IO_DIGITAL_INPUT); io_configure(7, IO_DIGITAL_INPUT); io_configure_pullup(0, 0); io_configure_pullup(2, 0); io_configure_pullup(3, 0); io_configure_pullup(4, 0); io_configure_pullup(5, 0); fivebyfivedisplay.sprite_scroll((new StringSprite('Hello World!', 'R')), 100, 'L'); fivebyfivedisplay.sprite_scroll((new StringSprite('Hello World!', 'R')), 100, 'R'); fivebyfivedisplay.sprite_scroll((new StringSprite('Hello World!', 'D')), 100, 'U'); fivebyfivedisplay.sprite_scroll((new StringSprite('Hello World!', 'U')), 100, 'D');