i need help today! thanks!

Status
Not open for further replies.
H

hjwhjkl

Guest
How to do with 2.0, i need the code.

5. Writing Strings to the LCD (1 mark)
Display your name, student number, and “Press any button” on three separate lines on the LCD screen.
6. Clearing and drawing to the screen (1 mark)
Display a bounding box around the edge of the screen that is a single line of pixels around the edge of the screen.
7. Move a bullet across the screen (1 mark)
Draw a bullet (character ‘-‘) moving to the right across the screen. It should start in the top left of the screen and move to the top right of the screen.
8. Reacting to Button Presses (1 mark)
Write a program that reacts to button presses (debouncing must be implemented for correct functionality). Change between the three screens in order every time a button is pressed. Note that the screens must be in this order, and the screen should change back to screen 1 after screen 3.
1. Name, student number, and “Press any button”
2. Bounding box
3. Bullet moving right across the screen from the top left to the top right QQ图片20150427201142.png
 
Last edited:
You didn't say which particular type of LCD you're using. So instead of advice very specific to your hardware, I'm going to guess you've got one of the regular character type LCDs.

http://www.pjrc.com/teensy/td_libs_LiquidCrystal.html

You can see on that page how to connect it to Teensy 2.0. The slow 6 signal connection is fine.

In Arduino, you can find examples in File > Examples > LiquidCrystal. There's a HelloWorld example that will instantly let you display a message, gaining you at least the first mark on your assignment. How's that for easy?!

For reacting to buttons, I highly recommend using the Bounce library. For example, look in File > Examples > Teensy > USB_Keyboard > Buttons. Instead of Keyboard.print, you'll use lcd.print. I'm not going to give you everything in this message (especially since you didn't even put the effort into saying exactly what type of LCD you're using... you only copied what appears to be school assignment)

If you want more help, you really need to write better questions. Ideally, your question should show the work you've already tried so far (assuming there is any at all) and where you've become stuck. You can get much better help on forums like this if you show that you have actually tried and hit a problem. Simply posting a school assignment without demonstrating any work or effort does not make a good impression. A bad impression tends to discourage people from helping.
 
hmmm, tried to restrain myself but it seems the urge will just bug me till I post:


Assuming that this is an exam at the end of some sort of course; if you study the "study materials" and complete some of the "exercises", from the 'course-work', then the exam will be a lot easier because it is just designed to verify that you have gotten a reasonable gist of the subject some (likely) underpaid soul has just spent the last few months trying to get you to pay attention to.


@stevech: classically apt imho, however a little subtle perhaps. I hope I remember it next time it would be so apt and hasn't been posted yet ;)
 
yeah, u are right. i tried to finished the question 5,6 and 7. and the code as below. i really can not understand the question 8 which press button to change the screen.
the code as below:

#include <avr/io.h>
#include "graphics.h"

int main() {
LCDInitialise(LCD_DEFAULT_CONTRAST);
clear();


draw_string("Kangze Hou",5,10);
draw_string("n8816662",5,20);
draw_string("Press any button",5,30);


for (int i = 0; i<=40; i++) {
draw_string("|",0,i+1);
draw_string("|",80,i+1);
}
for (int i = 0; i<=80; i++) {
draw_string("-",i+1,0);
draw_string("-",i+1,40);
}
draw_bullet();
refresh();
return 0;

}

void draw_bullet();
void draw_bullet(){
for (int i = 0; i<=80; i++) {
clear();
draw_string("-",i+1,2);
refresh();
}
}
 
assuming it does, because I am not in a position to compile it and expect the same result as you at all, if the following copy of your code compiles then you can use bounce to take care of a button for you and all you really need to do is google 'teensy 2.0 bounce button' and look for one which uses Bounce.h and has detail about physically connecting the button.

If your compiler was compiling the code you showed in the post above but does not compile the following, complaining cannot find Bounce.h, then you will need to google more along the lines of 'teensy 2.0 use digitalRead to read a button debouncing method' but a lot of the search results will probably be very noisy with mentions of the Bounce library.

Code:
#include <avr/io.h>
#include <Bounce.h> 
#include "graphics.h"

int main() {
	LCDInitialise(LCD_DEFAULT_CONTRAST);
	clear();

	draw_string("Kangze Hou",5,10);
	draw_string("n8816662",5,20);
	draw_string("Press any button",5,30);

	for (int i = 0; i<=40; i++) {
		draw_string("|",0,i+1);
		draw_string("|",80,i+1);
	}
	for (int i = 0; i<=80; i++) {
		draw_string("-",i+1,0);
		draw_string("-",i+1,40);
	}
	draw_bullet();
	refresh();
	return 0;

}

void draw_bullet();

void draw_bullet(){
	for (int i = 0; i<=80; i++) {
		clear();
		draw_string("-",i+1,2);
		refresh();
	}
}
 
this is code can not work well. i have no idea about question 8
 
The assignment requires debouncing - I doubt the instructor's intention was for the student to use a library (someone else's work) with debounce capability. Rather than DIY so a debounce technique is learned.

This student needs to know that when job-seeking, the lack of depth of understanding of basics will be immediately apparent.
 
Last edited:
lol, you the Teacher Frank?

@stevech: Yeah, between the supply of 'graphics.h' and the environment that code must be for; I am betting Bounce isn't even there - doubtful that digitalRead (or anything else all that 'arduino-esque') is there to use either.
 
Yeah, It takes a lot of cahones to use the thread title then post the assignment verbatim, then demand code be sent.

Out here in the real world, we can just go down the hall to a peer engineer's office and do the same.

Riiiiiiiight.
 
i usually don't get into these types of threads, but dude, your numbered list is not even in order and i can barely follow what you are trying to ask or demand. Anyway good try.... not!!! take these comments as a guide on how to ask for help on homework problems more discretely so not tip off all the folks who will call you out if they suspect such.;)
 
Status
Not open for further replies.
Back
Top