The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
Dev Shed Forums
> Programming Languages
> C Programming
Program C
Discuss Program C in the C Programming forum on Dev Shed. Program C C programming forum discussing all C derivatives, including C#, C++, Object-C, and even plain old vanilla C. These languages are low level languages, and used on projects such as device drivers, compilers, and even whole computer operating systems.
Dev Shed Forums Sponsor:
December 23rd, 2012, 05:25 AM
Registered User
Join Date: Dec 2012
Posts: 4
Time spent in forums: 1 h 21 sec
Reputation Power: 0
Program C
Hi everybody
I want to write a program in C language or algorithmic that change Value of integer "x"
from 0--->333 then 333-->0 and repeat this action forever.
Thank you
December 23rd, 2012, 06:05 AM
Cool! Good luck with that, and let us know how it works out for you!
__________________
I ♥ ManiacDan & requinix
This is a sig, and not
necessarily a comment on the OP:
Please don't be a
help vampire !
December 23rd, 2012, 02:18 PM
Contributing User
Do you need a program that wastes cpu time (to use as a resource disrupting virus) or a program that doesn't return?
__________________
[code]
Code tags [/code] are essential for python code!
December 23rd, 2012, 11:04 PM
Registered User
Join Date: Nov 2011
Posts: 11
Time spent in forums: 2 h 18 m 52 sec
Reputation Power: 0
I see, and is this program actually supposed to accomplish anything?
December 24th, 2012, 01:28 AM
Contributed User
Here's half of it (kind of
)
Code:
for ( int i = 0 ; i <= 0xdb ; i++ ) printf("%03o\b\b\b",i);
Also cross-posted
Apparently (since there's a nice picture there which we didn't get), the OP wants to generate a sawtooth wave.
(content is in Arabic, so I used google translate).
Last edited by salem : December 24th, 2012 at 01:36 AM .
December 24th, 2012, 05:02 AM
Registered User
Join Date: Dec 2012
Posts: 4
Time spent in forums: 1 h 21 sec
Reputation Power: 0
Hi,
Yes I want to program a PWM signal (Pulse width modulation) and send it to DSP
The objective is to varying brightness of the Led by changing variable x
x = 333 ---> 100 % of brightness
x= 166 ---> 50 % of brightness
x= 0 ---> 00 % of brightness
I want to increase brightness from 0% -----> 100% then decrease it from 100% -- 0%
I'm using actually this program
Code:
while(1)
{
brightness++;
TIM4->CCR3 = 333 - (brightness + 0) % 333; // set brightness
Delay(0x11111);
}
But it doesn’t work like I want,
This program work like this 0% ---> 100% then repeat the same think 0% ---> 100%
Thank you
December 24th, 2012, 06:33 AM
Contributed User
So put both elements in your loop
Code:
while ( 1 ) {
// code for 0% to 100%
// code for 100% to 0%
}
December 24th, 2012, 06:46 AM
Contributing User
As a single function:
abs(166-brightness%333)
December 24th, 2012, 07:25 AM
Registered User
Join Date: Dec 2012
Posts: 4
Time spent in forums: 1 h 21 sec
Reputation Power: 0
Quote:
Originally Posted by b49P23TIvg
As a single function:
abs(166-brightness%333)
Thank you, the brightness in your program works from 50% ---> 0% ---> 50%
I change it to 100% ---> 0% ---> 100% using this modification
Code:
abs(333-brightness%666)
Thank you for all responses
Comments on this post
b49P23TIvg
agrees: Whoops!
Developer Shed Advertisers and Affiliates
Thread Tools
Search this Thread
Display Modes
Rate This Thread
Linear Mode
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off