I want to write a program in C that takes the input of the potentiometer in the pickit. The program should rotate the 4 LED in the pickit board left or right depending on the direction that the potentiometer has been rotated. if the arrow of the potentiometer points to the right the LED's should start to rotate to the right. Also the speed of rotation of the LED's should depend on how far from the center the arrow on the potentiometer points. Moreover, I would like to use the pushbutton on the board as a pause switch. So when the pushbutton is pressed the LED's should stop at their current position even when the potentiometer is rotating. Any help would be appreciated thanks.
Related
I am trying to do a navigation system like google cloud infrastructure like this:
google cloud infrastructure.
I want to do this using aframe rather than threejs. So I am now customising aframe orbit control by keven ngo:
aframe orbit control.
The problem is that, I succeeded in limiting the auto rotation in a certain angle, so as pan. But I have some following problem that I do not know how to do after searching every posiblities and tried my self:
how to achieve the same effect of bouncing back smoothly after reaching out the pan limit;
for some reason if I pan and after mouseup then when mouse moves, it still pans rather than rotate. Why is that?
how to make camera rotates slightly like in google's example(I modified the original library to rotate camera when mousemove rahter than mousedown)?
Below is the glitch link of my experiment:
aframe customized orbit control
what I customized(I notated my change with slashes and ADDITION text):
autorotates between set angle;
mouse click only pans; when mouse move, camera rotates and autorotate stops;
pan can be limited.
This is a long question, very appreciated if anyone can help!!
how to achieve the same effect of bouncing back smoothly after reaching out the pan limit?
One idea: on mouseup (ie release of pan mode), check if the camera target is outside of the camera's viewing frustrum. If so, calculate a new target position, say half way between current target position, and a point in line with the camera z axis( ie, the center of the screen). Then make an animation, that moves the camera target from current location, to new location.
for some reason if I pan and after mouseup then when mouse moves, it still pans rather than rotate. Why is that?
It seems that the navigation mode (panning, orbitting,or zooming), does not change on mouse up. Make a new (mouseup) listener, that forces orbit mode back to a default mode (orbit?).
how to make camera rotates slightly like in google's example(I modified the original library to rotate camera when mousemove rahter than mousedown)?
It looks like in the google example, orbit direction is determined by which side of center the cursor is in. Left side makes autorotate go clockwise, and right side counterclockwise. You will need to use the cursor component to detect this, and change the orbit direction accordingly.
Also, it appears that in the google version, orbitting is not determined by mousedown (ie dragging), but by cursor distance to center, and this is added to the auto rotate. It appears to be a buffer system, where distance to center initially creates a value to alter the auto orbit (by adding or subtracting to the orbit amount), but that value is a buffer, meaning that it degrades to 0 over time (each frame the value is reduced slowly to 0).
I just recently began using Unity3D and this is my first game, so if I'm not doing things like I'm supposed to, please tell me.
There is a 2D character that I want to move one step forward using the Animation mechanism. This movement can be splitted in two parts :
Move forward the back leg, don't move the upper body ;
Use this leg to push and make the step, moving the upper body.
My problème is that I can't find a way to make this step permanent. As soon as it start looping on the "Idle" animation, then, it come back to the original position (before the step).
I don't know how to let my character stay in the position it was just between the "Step Forward" animation and the "Idle" animation.
I tried to add "Rigidbody 2D", "Box Collider 2D" and "Physics2D Material" on both feet and on the floor, but it somewhat breaks the IK script ("Simple CCD", from the youtube video "Unite 2014 - 2D Best Practices In Unity"). And I'm sure there is a much simpler way.
EDIT: My question was not clear enough. The idle animation is the default animation, where the character is doing nothing in particular. It's just moving a little while it's staying in position. When it runs "Step Forward", all the sprites are moved (only when the back leg is pushing). If all animations are stopped right now, then the character is indeed in a new position, closer to it's opponent. I can check that by removing the transition from "Step Forward" to "Idle". But from here, I want it to loop on the Idle animation. When the transition from "Step forward" to "Idle" is done, the character is NOT running Idle from it's new position, but from it's old position, before the step, as if it was pulled from backward. I want to run Idle from the new position.
Here is a longer gif when we can see more of the Idle animation :
And my Hierarchy panel looks like :
Main Camera
Karateka (the top GameObject container, with the Animator component)
Torso (the sprites)
Head
Right arm
Right leg
Right lower leg
Right foot
...
IK (the Inverse Kinematics targets)
Left fist target
Left foot target
...
Any suggestion is welcome.
If I get it right, you have the StepForward animation running and it gets cut in the middle back to idle. There, the StepForward animation triggers again but from the start and you wish to restart from where you left off:
You can record the normalized value of your StepForward animation and use it next time:
float normValue = this.animator.GetCurrentAnimatorStateInfo(0).normalizedTime;
then you can use that value:
this.animator.Play("StepForward", 0, normValue);
Other possibility, you are not after that but simply you want to pause the animation without getting to Idle.
Use a parameter. You can add a float parameter (call it direction) in the Animator window (top left). Then select a state in the animator, it will open the animation setting in the inspector. Under speed, open the drop down where your new parameter should show up. And tick it.
Now, your direction float will affect the speed of your animation as such:
this.animator.SetFloat("direction", value);
if you give 0, you pause. Give back 1 to move forward. You can also lerp the value so it is not abrupt. Your way.
I am making a simple JavaScript game using Phaser and it is going pretty well. I am currently having a few issues with the rotation of the tank, however.
Issue 1:
When shooting the bullet (left click) the speed is dependent on the distance from the tank to the mouse. The code I am currently using to get the rotation of the tank involves subtracting the mouse x and y from the tank x and y. The bullet receives the velocity from these values. How would I go about keeping the velocity consistent no matter what the distance of the mouse is?
Phaser has a native method for this I did not know about.
Issue 2:
If you click to shoot a bullet and turn quickly, you can see the bullet under the barrel of the tank. This is more a a visual "glitch", but I would like to have the bullet spawn right at the edge of the barrel of the tank. Is there a method to get the correct spawn location based on both the rotation and barrel position?
I am currently coding a little AR-Game for myself on the iPhone 3GS ;-)
I want to use the accelerometer & compass data for rotating my camera in opengl. The camera has a fixed position and can only rotate due to the accelerometer. The iPhone is initially rotated 90° to have a bigger widescreen ;-) So the axes are switched...
When I hold the iPhone straigt in front of me I get these values:
accel.x = 1
axxel.y = 0
accel.z = 0
When move the iPhone straight to the top of me (over my head) I get these values:
accel.x = 0
accel.y = 0
accel.z = 1
So the values are between :
x: 1 straight ahead and 0 over my head
y: 0 straight ahed and 0 over my head
z: 0 straight ahead and 1 over my head
I want to use x, y, z for my camera world coordinates. E.g. accel.x = 0.5 and accel.z = 0.5
The camera should change the centerX, centerY and centerZ values based on the values I get from the accelerometer.
How can I manage this?
Thanks ;-)
If you're getting X=1 with the phone straight ahead of you, it sounds like you're holding the phone in landscape, with the button to the right, is that correct?
The accelerometer reports gravitational force, so X=1 means that you're going DOWN the X-axis on the screen.
This means that your +X direction (pixels) on the screen is really the +Y direction (gl drawing) in your OpenGL world, which corresponds to a -X accelerometer reading.
In this orientation, moving the phone to your left & right will give +Y and -Y accelerometer readings, respectively. How strong the readings are depend on with how much force you move the phone. If you move slowly, the reading may be indistinguishable from normal noise in the data. If you move at about the speed that the phone would fall if you dropped it, your reading will be close to "1" ("1 G-force" or "1 gravity.") If you move it faster than that, you will get higher readings.
NOTE: if you just turn, then stop moving, the accelerometer reading will revert to 0. Gravity is an measure of acceleration ("the acceleration due to gravity"!), not facing. This is why the compass became important.
If you tilt the phone screen-down or screen-up, the accelerometer's Z-reading will change, as gravity pulls "into" or "away from" the screen. With the screen perfectly vertical (as holding the phone straight in front of your face, any orientation), the accelerometer Z-reading should be 0.
How you translate that orientation data to your camera depends on your app. Just keep in mind that "steering" the camera by moving the phone will be tricky to get right, as you have to account for both acceleration AND deceleration of the user's movements!
To help you visualize this, check out XCode's sample-project "Accelerometer." Just search that word in the documents, and you'll see a sample project you can build and play with to get an idea of what each axis means.
Luck!
I'm looking to create a jog wheel in an iPhone / iPad application. I know that you can subclass UIGestureRecognizer to write your own recognizers. Does anyone know how (mainly the maths behind it) to create one that would detect a circular movement, perhaps in combination with a pan gesture?
Thanks
this question isn't easy. I spend some time thinking of a possible solution:
I think what you need are some key properties you have to set:
The center of the circular movement (in this case no problem, because you know the center of the jog wheel)
A corridor in which the movement should happen.
so you need the inner radius and the outer radius.
Now you have something like this (unfortunately I haven't got enough reputation so only the link: http://img17.imageshack.us/img17/4416/bildschirmfoto20100721u.png
Now the maths behind this starts:
First of all you arrange the corridor in four quarters:
From 0° to 90°
From 90° to 180°
From 180° to 270°
From 270° to 360°
For each quarter you have to figure out when the finger is moving (let's say that the 0°-line is from the center point straight to the top):
if the finger is in the first quarter you know if the x changes to the left that the rotation must be anti-clockwise. If the x changes to the right the rotation must be clockwise.
Apply this logic for all quarters. Now you know if the jog wheel is moved clockwise or anti-clockwise. You have to make sure, that the finger is never leaving the corridor (if you test this logic and the movement stops because of leaving the corridor, make the corridor bigger - Thanks to CrystalSkull for his comment: Use 44px as a minimum width for the corridor to apply to the Human Interface Guidelines).
Sumary
So now you can conclude that you need a center point and a corridor the finger can move in.
You have to figure out in which quarter the finger is in and find out (using the x-value) if the rotation is clockwise or anti-clockwise.
I hope this helps you a little bit.