Example: Note, this flashes the LEDs as well for effect, they aren't needed here. #include #include #include #include #include #include #include #include #define ERROR -1 int fd; void sighandler(int signum); void main() { int lednum; int i, j, k; /* To be used as the fd in ioctl(). */ if ((fd = open("/dev/console", O_NOCTTY)) == ERROR) { perror("open"); exit(ERROR); } printf("w00w00!.\n\n"); /* We don't want an LED still on after we quit. */ signal(SIGINT, sighandler); signal(SIGTERM, sighandler); signal(SIGQUIT, sighandler); signal(SIGTSTP, sighandler); printf("For the best sounding one, use the example values shown.\n"); printf("To exit hit Control-C.\n"); while (1) { printf("Enter range of tones to play (i.e. 100-3000): "); scanf("%d%*c%d", &i, &j); printf("Enter intervals to skip (i.e. 10): "); scanf("%d", &k); printf("Doing %d through %d, with an interval of %d:\n\n", i, j, k); for (; i <= j; i += k) { for (lednum = 0x01; lednum <= 0x04; lednum++) { if (lednum == 0x03) continue; usleep(10000); if ((ioctl(fd, KDSETLED, lednum)) == ERROR) { perror("ioctl"); close(fd); exit(ERROR); } } if ((ioctl(fd, KIOCSOUND, i)) == ERROR) { perror("ioctl"); close(fd); exit(ERROR); } printf("%d\n", i); if (i == j) break; usleep(70000); } /* Turn off all sound. */ if ((ioctl(fd, KIOCSOUND, 0x0)) == ERROR) { perror("ioctl"); close(fd); exit(ERROR); } /* Turn off all leds. */ if ((ioctl(fd, KDSETLED, 0x0)) == ERROR) { perror("ioctl"); close(fd); exit(ERROR); } putchar('\n'); } close(fd); /* Will never get this far. */ } void sighandler(int signum) { /* Stop all sound. */ if ((ioctl(fd, KIOCSOUND, 0x0)) == ERROR) { perror("ioctl"); close(fd); exit(ERROR); } /* Turn off all leds. */ if ((ioctl(fd, KDSETLED, 0x0)) == ERROR) { perror("ioctl"); close(fd); exit(ERROR); } printf("\nw00w00!\n"); close(fd); exit(0); }