Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

desperate for help with gui in c#

Status
Not open for further replies.

Vandal S

Member level 3
Joined
May 2, 2009
Messages
54
Helped
3
Reputation
6
Reaction score
1
Trophy points
1,288
Activity points
1,749
gui with c#

short story
I desperately need a code for controlling dc motors attached to a pic 16f via h bridge with rs232 protocol.
Motors are controlled on and off. the problem is multiple key press. it's a car with 4 dc motors and 2 most important motors (speed and direction) are controlled by w a s d. the other 2 are optional and controlled with 8 4 2 6.

the long story
i am an absolute beginner in oop and c#. i have searched for days something that i need and except a gui from microsoft robotics studio [and that's not functional,at least according to my knowledge] i have found nothing. it's not that difficult, it's like controlling leds, on and off, no speed controll or fancy stuff, except that there is a h bridge somewhere in the circuit.
please, give me (and I thing that there are many interested; from this simple example, speed controll and other stuff could be added) an example close to what i need; the only thing that i can do at this moment is modify the visual style, but no programming so i am stuck. i have found simpleserial, a project in c# which echos a character, and except for the send part (which will be a binary vector, not the character that was pressed, the rest remains the same). the problem is key press events and multiple key pressed.
i was thinking of modifying the first value of the byte if w is pressed, and so on, the second value if s is pressed.
so, at the beginning there will be transmitted 10101010 for synchronizing (as there are rf modules between) and the data byte. if w and a are pressed, the data byte would be 1010 0000 . first 4 bits from wasd and the last from 4826.

it would be a very good thing if someone would do this in a couple of minutes because there are a lot of questions about gui, but no simple example.or at least i haven't found one.

other questions would be: how to implement the start and the stop bit?
 

onkeydownhandler(object sender, keyeventargs e)

You can download and use Visual C# Express from Microsoft here:

https://www.microsoft.com/express/vcsharp/

It is free and very easy to use to develop a gui.
There is a serial port component that you can drag and drop onto your form to give you serial comms.
It should not be hard to capture key presses.
 

e.keydata c# multiple keys

actually that is the hard part. i was able to transmit something to serial, so that part is ok, but capturing multiple keypress.. that's the problem. what functions to use? key release, keypress?
 

capture multiple key press in c#

Use the Key event KeyPress.
 

multiple key press in c#

Code:
private void OnKeyDownHandler(object sender, KeyEventArgs e)
{
    if (e.Key == Key.Return)
    {
        //your code
    }
}
 


quicksharp c#

i'm still having problems with the code
so all i need is a form with 2 buttons, if i press one of them or w, a message appears with "up", if a press the other button or "s" appears "down".
i clicked on one button and then went in right-down part of the screen and selected from events keypress, and when i double clicked, i was trying to write this code but doens't work [i know that there should be code for 2 buttons, but i don't know how to integrate events and the switch - case stuff

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{

public void Form1_KeyDown(object sender, KeyEventArgs e)
{
switch (e.KeyData)
{
case Keys.W:
{
MessageBox.Show("up");
} break;
case Keys.S:
{
MessageBox.Show("down");

} break;
}
}
}
}
 

multiple keypress in c#

ok.. i lost a lot of time but i found out a very important piece of advise: if you're copying code from the internet [not a whole project], use quicksharp. the big c# with it's hundreds of mb will get you into trouble. most of you probably knew how to modify the code to work, but for me it's a valuable info.
i managed to make a form and when a is pressed, a textbox appears and says "a"; when b, it says "b" and so on. but what about multiplekey presses?
how can i press a and b and two independent textboxes appear?
or 2 things on the form to appear and remain for as long as one of the key remains?(2 leds or something grafic)
 

for those of you who worried about the desperate need, good news: i managed to make a small step, but a big one for the project. using GetAsyncKeyState i was able to see in a console the result of 2 simultaneus key presses. it's not button operated, or mouse-click-button operated but it's something
 

Glad to see you are making progress.
The best way to learn is by solving the problems yourself. There is a lot of help in the help files and on the web, but nothing as valuable as having to try till you get it right and understand it yourself.
After this project I have no doubt you will be a C# hacker!
 

    Vandal S

    Points: 2
    Helpful Answer Positive Rating
at least one of us has faith in me :D
if i had more time, i wouldn't have posted on forums, but tried to get the anwer my self, but i'm kind of desperate; important and big project that should have been done by now, and i'm at the beginning with very few knowledge
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top