Thread: Pointer to pwm
View Single Post
  #2   Spotlight this post!  
Unread 05-02-2008, 19:56
dcbrown dcbrown is offline
Registered User
AKA: Bud
no team
Team Role: Mentor
 
Join Date: Jan 2005
Rookie Year: 2005
Location: Hollis,NH
Posts: 236
dcbrown has much to be proud ofdcbrown has much to be proud ofdcbrown has much to be proud ofdcbrown has much to be proud ofdcbrown has much to be proud ofdcbrown has much to be proud ofdcbrown has much to be proud ofdcbrown has much to be proud ofdcbrown has much to be proud ofdcbrown has much to be proud of
Re: Pointer to pwm

Code:
typedef struct
{
     // stuff
     unsigned char* pwm;
} Motor;

void InitMotor( Motor* motor, unsigned char* pwm, /* more parameters */ )
{
     // stuff
     motor->pwm = pwm;
}

then if I want to change the motor speed
Motor myMotor; InitMotor( &myMotor, &pwm10 );
*myMotor.pwm = 127; // set it to nuetral
need * to dereference the pointer and & to pass a pointer in the places shown

Last edited by dcbrown : 05-02-2008 at 20:12.